2015-12-13 160 views
1

我要讓我的主頁重定向到非HTTPS如果HTTPS
如果https://example.com會重定向到http://example.com ,我想用SSL(只是目錄目錄使用SSL)重定向HTTPS非HTTP和HTTP到HTTPS在目錄中的htaccess

如果http://example.com/directory西港島線重定向到https://example.com/directory

我使用這個:

RewriteEngine On 
RewriteCond %{HTTP_HOST} !^www\. 
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L] 

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

但它只是顯示循環

回答

1
RewriteEngine On 

RewriteCond %{HTTPS} ^on$ 
RewriteCond %{REQUEST_URI} !^/dir 
RewriteRule (.*) http://%{HTTP_HOST}%{REQUEST_URI} [R=301,L] 

RewriteCond %{HTTPS} ^off$ 
RewriteCond %{REQUEST_URI} ^/dir 
RewriteRule (.*) http://%{HTTP_HOST}%{REQUEST_URI} [R=301,L] 
+0

你能告訴我,爲什麼它重定向到'example.com.com'嗎? ( –

+2

)清除您的緩存並重試。您的規則是永久性重定向,它們可能被緩存! – undone

+0

我的css和js不工作,發生了什麼?有什麼錯? –

相關問題