2013-04-15 31 views
0

我使用.htaccess在某些頁面上強制https,在其他頁面上強制使用http,並且它工作正常。但我需要在主頁(example: http://website.com)上強制http,我不知道該怎麼做。我試過RewriteCond %{REQUEST_URI} ^/index.php/?,但因爲我使用的drupal沒有工作。使用.htaccess在主頁上強制使用http

這是我使用的腳本:

RewriteEngine on 
RewriteCond %{SERVER_PORT} 80 
RewriteCond %{REQUEST_URI} ^/register/? [OR] 
RewriteCond %{REQUEST_URI} ^/admin/? 
RewriteRule ^(.*)$ https://website.com/$1 [R,L] 

RewriteCond %{SERVER_PORT} 443 
RewriteCond %{REQUEST_URI} ^/about-us/? [OR] 
RewriteCond %{REQUEST_URI} ^/help/? 
RewriteRule ^(.*)$ http://website.com/$1 [R,L] 

任何幫助表示讚賞

回答

1

首先,取代RewriteCond %{SERVER_PORT},您可以使用RewriteCond %{HTTPS},這應該是在HTTPS檢測更加可靠。

該主頁有RewriteRule模式^$。所以規則是

RewriteCond %{HTTPS} =on 
RewriteRule ^$ http://website.com [R,L] 

如果一切正常,你期望的那樣,你可以改變RR=301

+0

非常感謝,這非常有幫助。 –

相關問題