简体   繁体   中英

force https on a single page, and then redirect other requests to http

hello so basically i have a single page that i want to have https, i want its children and siblings to have http only.

i have the code working some what, however if i click a link from my ssl page to a non ssl page the https still stays., i am trying to get it to redirect back to http

here is what i have so far

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]

main goal is to force www at all times as well as trailing slash also want to force https only on https://www.domain.com/prepaid/ and then any childeren or sibliligs im trying to force http. even if you are on the https page and you click away (this is what im stuck on, it currently stays in https)

try this:

<Location /sample.php>
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
</Location>

rename sample.php to your filename

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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