[英]Using .htaccess, How to force HTTPS without conflicting with other RewriteRules?
我的.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]
由於某些原因
#RewriteCond %{HTTPS} off
不工作
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.