繁体   English   中英

在单个页面上强制使用https,然后将其他请求重定向到http

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM