・環境は
FreeBSD apache 1.3.x
・したいこと
(1)http://xxx.com/store/index.html?c=category&g=group
↓
http://www.com/store/category/group.html
(2)http://xxx.com/store/index.html?c=category
↓
http://www.com/store/category/
(3)http://xxx.com/store/index.html?g=group
↓
http://www.com/store/
上記に加え、元のパスの「index.html」は無しの場合にも
対応させたいと思います。
よろしくお願いします。
DirectoryIndex でパラメータを与えると store/?c=... がうまくいかない様なので
DirectoryIndex index.html RewriteEngine on RewriteRule ^([^/]+)/ index.html?c=$1&%{QUERY_STRING} RewriteRule /([^/]+)¥.html$ test.php?g=$1&%{QUERY_STRING} [L] RewriteCond %{QUERY_STRING} ^$ RewriteRule ^$ index.html?g=group
でどうでしょうか?
.htaccess は、/store に置く。
/store 配下には、指示する名前(=category)のファイルもディレクトリも存在しない。
/store/category 配下には指示する名前(=group.html)のファイルは存在しない。
の予定で書きました。検証が十分でないかも知れませんが、
/store/
/store/category/
/store/category/group.html
/store/index.html?c=par1&g=par2
/store/?c=par1&g=par2
に対応出来ていると思います。
ついでに、
c=... g=... 以外のクエリが追加されてもOKです。
例えば、
/store/category/group.html?a=123
のアクセスは、
/store/index.html?c=category&g=group&a=123
に置き換えられます。
www.com → xxx.com のようにドメインまで指定するとどうしてもリダイレクトしてしまうような気がします。
DirectoryIndex index.html?g=group RewriteEngine On RewriteCond %{REQUEST_URI} /$ RewriteRule ^(.+?)/ http://xxx.com/store/index.html?c=$1 RewriteEngine On RewriteRule ^(.+?)/(.+)\.html?$ http://xxx.com/store/index.html?c=$1&g=$2
group.html → g=group
dog.html → g=dog
cat.html → g=cat
のように解釈しましたが、(3)の時は無条件に g=group になるのでしょうか?
あと、
> 元のパスの「index.html」は無しの場合
というのもよく分かりませんでした。