我已经在网站上放置了一个 htaccess 文件,内容如下
<Files ~ "^\.(htaccess|htpasswd)$">
deny from all
</Files>
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www\.ic-furniture\.com)(:80)? [NC]
RewriteRule ^(.*) http://ic-furniture.com/$1 [R=301,L]
order deny,allow
redirect 301 /index.php http://ic-furniture.com/
redirect 301 /index.html http://ic-furniture.com/
ErrorDocument 404 http://ic-furniture.com/404.html
我想做的是
- 删除 www。
- 删除/index.html
- 如果有人点击 site/index.php 的链接,我希望他们转到主页
- 404错误页面到404.html
但是当我上传这个时出现错误
The page isn't redirecting properly
Firefox has detected that the server is redirecting the request for this address in a way that will never complete.
知道我在这里做错了什么吗,我一直在疯狂地试图找出答案
最佳答案
您应该使用%{THE_REQUEST}
变量来检查实际请求是否针对索引文件,然后进行相应的重定向:
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.(php|html)
RewriteRule ^ http://ic-furniture.com/ [L,R=301]
关于.htaccess - htaccess陷入无限循环,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15927789/