ファイルが .php だとSEO的によくないらしい。
Apacheのmod_rewriteを使うと、.php も .html でアクセス可能になり、SEO的にいいらしい。
(1)Apacheにmod_rewriteを組み込む。
(Apacheのソースのあるディレクトリに移動後)
$ ./configure --enable-so --enable-rewrite
$ make
$ su
# make install
(2)Apache再起動
(3)対象のディレクトリ下に .htaccess 作成。ここでは www.hoge.com/shop/に割り当てているディレクトリ下。
DirectoryIndex top.php
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteBase /shop
RewriteRule index.html top.php RewriteRule ^index\.html$ top.php (注)
RewriteRule ^show-([0-9]+).html+ show_data.php?param1=$1
RewriteRule ^show-([0-9]+)-([0-9]+).html+ show_data.php?param1=$1¶m2=$2
上記で、
https://www.hoge.com/shop/show_data.php?param1=10
が
https://www.hoge.com/shop/show-10.html
で、また
https://www.hoge.com/shop/show_data.php?param1=10¶m2=99
が
https://www.hoge.com/shop/show-10-99.html
でアクセス可能になる。
すごくいろいろな書き方ができ、制限もできるようだ。
mod_rewriteでぐぐると山のように情報アリ。
Module mod_rewrite URL Rewriting Engine 正統にマニュアル。。
動的だけど静的なページの作成 (mod_rewrite)
この対策でどれだけ効果があるのかに興味アリ。
(注)2005.9.7 訂正したようにしないと、xxxxxx_index.html のようなURLも対象として引っかかってしまう。