2014-02-11 104 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