这个.htaccess出了什么问题? Safari上的重定向过多

时间:2015-05-14 16:29:26

标签: php regex apache .htaccess mod-rewrite

有人可以告诉我,我的.hatcess有问题吗?

RewriteEngine On

RewriteRule \.(css|jpeg|jpg|gif|png|js|json|eot|svg|ttf|woff|txt|xml|ico)$ - [L]
RewriteRule . core/FrontController.class.php [L]

RewriteBase /
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]

Redirect 301 /index http://eese.com

问题:Safari说我必须进行多次重定向(只需转到http://eese.com

1 个答案:

答案 0 :(得分:1)

不要将Redirect规则与mod_rewrite规则一起使用。将.htaccess更改为:

RewriteEngine On
RewriteBase /

RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]

RewriteRule ^index/?$ / [L,R=301,NC]

RewriteRule \.(css|jpeg|jpg|gif|png|js|json|eot|svg|ttf|woff|txt|xml|ico)$ - [L]
RewriteRule . core/FrontController.class.php [L]

清除浏览器缓存后对此进行测试。