[Apache-Users 7644] .htaccess のrewriteルール
fujioka
qhtsige @ apost.plala.or.jp
2010年 3月 13日 (土) 12:41:17 JST
藤岡です。 .htaccess のrewrite ルールについて教えてください。
次のurl1,url2の場合、Internal server errorとなり、所望の変換ができません。
error.logを見ると、どうも%や/文字が入る正規表現を変換することができないように見えます。
どんな対策が良いでしょうか。
要求されたURL1 http://localhost/Rosa_/'Matilda/'.html
変換したいURL1 http://localhost/Rosa_'Matilda'.html /記号を削除。
要求されたURL2 http://localhost/Anemone%20debilis.html
変換したいURL2 http://localhost/Anemone_debilis.html %20を_記号に置き換える。
.htaccess
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([0-9A-Za-z_.'=-%]+)\.html$ htmpage2.php?yspec=$1 [L]
error.log
^([0-9A-Za-z_.'=-%]+)\.html$ の場合--> '^([0-9A-Za-z_.'=-%]+)\\.html$'
^([0-9A-Za-z_.'=-\%]+)\.html$ の場合--> '^([0-9A-Za-z_.'=-\\%]+)\\.html$'
^([0-9A-Za-z_.'=-/]+)\.html$ の場合--> '^([0-9A-Za-z_.'=-/]+)\\.html$'
^([0-9A-Za-z_.'=-\/]+)\.html$ の場合--> '^([0-9A-Za-z_.'=-\\/]+)\\.html$'
上記では、すべて全文では次のようになるが、略して書いた。
[Sat Mar 13 12:12:52 2010] [alert] [client 127.0.0.1] D:/upload/.htaccess:
RewriteRule: cannot compile regular expression
'^([0-9A-Za-z_.'=-%]+)\\.html$'
Apache-Users メーリングリストの案内