https到.htaccess中的http,但有异常

时间:2011-03-23 18:15:22

标签: linux http .htaccess redirect https

我已经做了足够的研究,弄清楚要将我的所有https页面整个站点重定向到它们的http等价物,我需要使用这段代码......

RewriteEngine On
RewriteCond %{HTTPS} on
RewriteRule (.*) http://%{HTTP_HOST}%{REQUEST_URI} [R=301,L] 

我的问题是,有一个页面句柄,我仍然希望保留为https。举例来说,假设我希望page1.php,page2.php和page3.php为REMAIN,为.https,网站上的其他内容都会重定向。有谁知道怎么做?

1 个答案:

答案 0 :(得分:0)

尝试这样的事情:

RewriteEngine On

# Force page1,2,3.php onto HTTPS
RewriteCond %{HTTPS} off
RewriteRule ^(page1|page2|page3)\.php https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L,QSA]

# Redirect other HTTPS requests to plain HTTP
RewriteCond %{HTTPS} on
RewriteCond ${REQUEST_URI} !(page1|page2|page3)\.php
RewriteRule (.*) http://%{HTTP_HOST}%{REQUEST_URI} [R=301,L,QSA]