我有几个重定向指令在我的。htaccess文件,我重定向所有调用到根文件夹到/Site文件夹,它工作得很好。
Options +FollowSymLinks
RewriteEngine On
# Redirect index in root to index in Site folder
RewriteRule ^index'.php$ /Site/index.php [PT]
RewriteCond %{REQUEST_URI} !^/Site
RewriteRule ^(/?)(.*) /Site/$2
我现在需要的是在所有页面上强制https,当我添加以下指令时,它不起作用,我相信它进入了无限循环:
#RewriteCond %{HTTPS} off
#RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
什么是正确的指令,使其工作?
我通过在RewriteEngine On
后面添加以下内容来解决这个问题RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
For some reason
#RewriteCond %{HTTPS} off
无效