.htaccess - htaccess陷入无限循环

标签 .htaccess http-status-code-301

我已经在网站上放置了一个 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/

相关文章:

html - .htaccess 301 将图像从旧图像重定向到新图像

php - 迁移到 https 后 curl 返回 301 错误

nginx - Gatsby 与 nginx - 重定向已损坏 - 尾随/(斜杠)

php - CakePHP 3 中的 301 重定向

apache - 从 301 重定向中删除查询字符串

.htaccess - https 页面上的 htaccess 重写规则

.htaccess - htaccess 重写规则 - 允许在 URL 中使用大写字母

.htaccess - 使用 htaccess 进行简单重定向

.htaccess - 将站点强制为 HTTPS,某些页面和 Facebook 爬虫除外

c# - 网站大修后重定向旧网址