这是我的.htacces文件:
RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_HOST} ^www.mysite.com [NC]
RewriteRule ^(.*)$ http://mysite.com/ [R=301,L]
RewriteRule .* index.php
RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_HOST} ^www.mysite.com [NC]
RewriteRule ^(.*)$ http://mysite.com/ [R=301,L]
RewriteRule .* index.php
它几乎将所有请求重写为index.php,但是当我在URL中放入反斜杠(\)时,就像
mysite.com/sth \然后它显示apache 404错误。怎么解决? firefox以外的浏览器替换\ to /但我希望它也可以在fx中工作。
我将AllowEncodedSlashes切换为On,但即使在apache重启后它仍然无效。
答案 0 :(得分:0)
您可以尝试以下代码。
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]
并确保在httpd.conf中启用allow override all,并在同一httpd.conf文件中启用mod_rewrite库。如果有效,请将其标记为已回答并竖起大拇指。