動的ページを静的ページに書き換え
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]
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]]
動的ページでも静的ページでもアクセスできることを確認。
問題なければ完了。
URL_DIR . "products/detail.php?product_id="
↓
URL_DIR . "products/details"
URL_DIR . "products/list.php?mode=search&category_id="
↓
URL_DIR . "products/lists"
/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