[英]force https on a single page, and then redirect other requests to http
你好,所以基本上我只有一個頁面,我想擁有https,我希望它的孩子和兄弟姐妹只有http。
我的代碼可以正常工作,但是,如果我單擊從我的ssl頁到非ssl頁的鏈接,https仍然停留。我正在嘗試使其重定向到http。
這是我到目前為止所擁有的
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !(.*)/$
RewriteRule ^(.*)$ $1/ [L,R=301]
RewriteCond %{SERVER_PORT} !^443$
RewriteRule ^prepaid/?$ https://www.domain.com/prepaid/ [R=301,L]
RewriteRule ^prepaid/h2o/?$ index.php?p=prepaid&s=h2o [L]
RewriteRule ^prepaid/?$ index.php?p=prepaid [L]
主要目標是在任何時候都強制使用www以及斜杠,並且也只希望在https://www.domain.com/prepaid/上強制使用https,然后再嘗試強制使用http的所有childeren或sibliligs。 即使您在https頁面上並單擊即可(這是即時消息,它當前停留在https中)
嘗試這個:
<Location /sample.php>
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
</Location>
重命名sample.php為您的文件名
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.