【发布时间】:2014-08-23 17:26:42
【问题描述】:
在使用 htaccess 做事时,我是一个初学者,所以请耐心等待我这个愚蠢的问题。我知道这已经解决了很多(例如here、here 和here),但它似乎不适用于我的情况。我的浏览器在我的 htaccess 文件中显示带有此代码的“重定向循环”错误:
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
# Redirect Trailing Slashes...
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
# Trying to redirect to https
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
</IfModule>
在我重定向到 https 之前,我知道这可能与 RewriteCond 和 RewriteRule 有关,但我真的不知道我在这里做什么,也不知道要更改什么.
更新:
更多可能有用的信息:
- 当我删除“重定向到 https”代码并手动输入
https://my.site.com时,它会正常加载。 - 此外,在我不小心删除了目录中的 .htaccess 文件之前,重定向到 https 的功能非常有效。
-
我尝试重定向的应用程序位于另一个应用程序的子文件夹中,该应用程序也有一个 .htaccess 文件。这是该应用程序的代码:
<IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] RewriteEngine On </IfModule>
萤火虫是这样说的:
【问题讨论】: