アットウィキロゴ

mod_rewrite

メニュー

動的ページを静的ページに書き換え

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^details([0-9]+).html+ detail.php?product_id=$1 [L]
RewriteRule ^lists([0-9]+).html+ list.php?category_id=$1 [L]
RewriteRule ^出力されるURL名([0-9]+).html+ detail.php?product_id=$1 [L]
RewriteRule ^出力されるURL名([0-9]+).html+ list.php?category_id=$1 [L]

URLの静的表現方法

phpの動的生成ページを静的ページに変換する。
クローラーの特性上、動的ページはインデックスされないので以下のようにして回避する。

以下のディレクトリに.htaccess作成

 /root/
    ∟data
    ∟html/products/ ここ

.htaccessの中身

 RewriteEngine on
 RewriteCond %{REQUEST_FILENAME} !-f
 RewriteCond %{REQUEST_FILENAME} !-d
 RewriteRule ^details([0-9]+).html+ detail.php?product_id=$1 [L]
 RewriteRule ^lists([0-9]+).html+ list.php?category_id=$1 [L]]

動的ページでも静的ページでもアクセスできることを確認。
問題なければ完了。

管理ページから以下変更

  • システム設定 → パラメーター設定 の DETAIL_P_HTML

URL_DIR . "products/detail.php?product_id="

URL_DIR . "products/details"

  • 同じく の LIST_C_HTML

URL_DIR . "products/list.php?mode=search&category_id="

URL_DIR . "products/lists"

下記対象ページのURL生成部分変更

/data/Smarty/templates/default/list.tpl
/data/Smarty/templates/default/bloc/best5.tpl
/data/Smarty/templates/default/bloc/category.tpl
/data/Smarty/templates/default/mypage/history.tpl
最終更新:2009年07月06日 00:22
ツールボックス

下から選んでください:

新しいページを作成する
ヘルプ / FAQ もご覧ください。