[英]How to redirect all to ssl and to index.php but not ssl but redirect all to index.php on a specific page
我希望所有人都強制重定向到https,但目前不在特定頁面上,我有此.htaccess文件:
RewriteEngine on
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?path=$1 [NC,L,QSA]
我希望所有人都重定向到https,但在特定頁面上強制使用http:/ exchage
要實現此功能,我需要在.htaccess文件中放什么代碼? 謝謝。
如何在HTTPS重定向中添加另一個條件以檢查路徑不是以exchange
開頭呢? (我認為您的年齡年齡拼寫錯誤)
RewriteEngine on
RewriteCond %{REQUEST_URI} !^/exchange
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{REQUEST_URI} ^/exchange
RewriteCond %{HTTPS} on
RewriteRule ^(.*)$ http://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?path=$1 [NC,L,QSA]
更新.htaccess文件后,請重新啟動瀏覽器。 否則,如果以前已經看到URL使用https,則可能會強制使用https。
我用這段代碼解決了這個問題。
RewriteEngine on
RewriteCond %{HTTPS} off
RewriteCond %{THE_REQUEST} !/exchange
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{HTTPS} on
RewriteCond %{THE_REQUEST} /exchange
RewriteRule ^ http://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?path=$1 [NC,L,QSA]
我花了將近3個小時才拿出這段代碼。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.