2014-02-11 103 views
0

因此,我已经尝试了很多不同的选项和配置。我试图将我的网站重定向到https,除了一个特定的URI,我想从https重定向到http然后保持http。我将不胜感激任何帮助。这是从虚拟主机配置完成的。以下是我已经与ssl.conf和mysite.conf配对使用的设置。但是,我一直在获取重定向循环或不加载的页面。Mod重写,将所有重定向到https,除了特定的URI,并将该URI从https重定向到http

mysite.conf

RewriteEngine on 
RewriteCond %{SERVER_PORT} 80 
RewriteCond %{REQUEST_URI} !/example 
RewriteRule ^(.*)$ https://my.site.com$1 [R,L] 

RewriteCond %{HTTPS} !=on 
RewriteCond %{REQUEST_URI} ^(/|page1|page2) 
RewriteRule ^(.*)$ https://my.site.com$1 [R,L] 

RewriteCond %{HTTPS} !=on 
RewriteCond %{REQUEST_URI} !=/example 
RewriteRule ^(.*)$ https://my.site.com$1 [R,L] 

RewriteCond %{REQUEST_URI} =/example 
RewriteRule ^(.*)$ http://my.site.com$1 [R,L] 

加上以上之一。

然后在ssl.conf中

RewriteEngine on 
RewriteCond %{REQUEST_URI} =/example 
RewriteRule ^(.*)$ http://my.site.com$1 [R,L] 

回答

0

这应该为你做它。首先放置最具体的规则(对于/example)。

RewriteEngine on 

RewriteCond %{HTTPS} =on 
RewriteRule ^/?example$ http://my.site.com/example [R=301,L] 

RewriteCond %{HTTPS} !=on 
RewriteCond %{REQUEST_URI} !^/?example$ 
RewriteRule ^/?(.*)$ https://my.site.com/$1 [R=301,L] 

这应该在服务器(.conf)或目录(.htaccess)上下文中工作。

+0

这有效,但有一个额外的问题,我可以注意到,一旦我使用配置,有一个额外的URI被调用,这是不是exlcuded列表的一部分,添加了附加条件语句工作。谢谢迈克。 – user3126479