duanmu0834 2013-03-19 03:51
浏览 54

在单个页面上强制执行https,然后将其他请求重定向到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)

  • 写回答

1条回答 默认 最新

  • duanfu3390 2013-03-19 04:00
    关注

    try this:

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

    rename sample.php to your filename

    评论

报告相同问题?