【发布时间】:2013-08-20 06:45:52
【问题描述】:
我的 .htaccess 文件有以下规则
# to redirect http to https
RewriteCond %{HTTPS} off
RewriteRule (.*) https://www.example.com/$1 [R=301,L]
# to redirect urls with index.php to /
RewriteCond %{THE_REQUEST} ^.*/index.php
RewriteRule ^(.*)index.php$ /$1 [R=301,L]
# to redirect non www requests to www url
RewriteCond %{HTTP_HOST} !^www\.example\.com
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]
当我尝试访问该网站时,它变成了一个重定向循环。如何解决此问题并正确重定向?
【问题讨论】:
-
哪个 URL 导致了重定向循环?
-
它们在一个空白的 htaccess 文件中对我来说都可以正常工作。您确定您的 https 重定向没有丢失
www? -
@JonLin 如果它对你有用,那么它应该对我有用。但它不起作用。是的,我的 https 重定向没有丢失
www。这是RewriteRule (.*) https://www.example.com/$1 [R=301,L]和www。我猜服务器设置或其他方面可能存在一些问题。