日本語文字列をurl_encodeしたものを引数に含めたURLをmod_rewriteで転送させようとするとエラーになります。
http://www.hoge.com/%82%A0.html
を以下にしたいのです。
http://www.hoge.com/entry.php?ID=%82%A0
.htaccessの設定ファイルは以下の通りです。
Options -Indexes +SymLinksIfOwnerMatch
<IfModule mod_rewrite.c>
<IfModule mod_dir.c>
DirectoryIndex index.php
</IfModule>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*).html$ entry.php?ID=$1 [L]
</IfModule>
引数が英数字だとうまく転送されています。例えば
http://www.hoge.com/aaa.html
です。
これはどのように解決できますでしょうか。
みなさんよろしくお願い致します。
手元の環境では、次のようなentry.phpを作成したところ、
<html> <body>id :</body> </html>
http://XXXX/%E3%81%82%E3%81%84%E3%81%86.html
できちんと、
id : あいう
と表示されました。
エラーになるとのことですが、どのようなエラーでしょうか?
entry.phpの実行によるエラーではないでしょうか?
(2) init rewrite engine with requested uri /あ.html
(1) pass through /あ.html
(2) init rewrite engine with requested uri /error/HTTP_FORBIDDEN.html.var
(1) pass through /error/HTTP_FORBIDDEN.html.var
(2) init rewrite engine with requested uri /error/include/top.html
(1) pass through /error/include/top.html
(2) init rewrite engine with requested uri /error/include/bottom.html
(1) pass through /error/include/bottom.html
(2) init rewrite engine with requested uri /error/contact.html.var
(1) pass through /error/contact.html.var
ローカル(Win)の環境だと上記の通り上手くいきません。
XREAだと問題なく動いています。
Apacheの設定の問題でしょうか?
ログに
> (1) pass through /あ.html
なんでデコードされたものが乗っている事自体がおかしい気もしますが。
勝手にデコードしてしまうのかもしれません。
Shift-JIS ではなく、UTF-8 や EUC でも同じ結果なのでしょうか?
そうなんですよね。
ログにデコード文字が書いてあるのは気になってました。
一応utf-8などでも試してみましたが、同じ結果になりました。
Apacheの設定の問題ならちょっと手に負えないんですよね。
Xamppのデフォルト状態からいじれませんし。