【问题标题】:What is wrong with this .htaccess? Too many redirects on Safari这个 .htaccess 有什么问题? Safari 上的重定向过多
【发布时间】:2015-05-14 16:29:26
【问题描述】:
谁能告诉我我的 .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)
【问题讨论】:
标签:
php
regex
apache
.htaccess
mod-rewrite
【解决方案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]
清除浏览器缓存后测试一下。