2016-04-27 124 views
0

我是一個在htaccess領域的初學者。從htaccess重定向排除子域。但重定向非www到www然後到https爲主域

我有以下規則現在

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

這可以幫助我實現以下

example.com => https://www.example.com 

但是,我需要排除的子域:

subdomain.example.com/myfile.html => http://subdomain.example.com/myfile.html 

哪有我達到了嗎?

在此先感謝您的答案。 注意:我嘗試了一些提供的解決方案。但他們都沒有爲我工作。

回答

0

您可以使用HTTP =以下規則>https://www

RewriteEngine on 

RewriteCond %{HTTP_HOST} !^sub\.domain\.com$ 
RewriteCond %{HTTPS} off [OR] 
RewriteCond %{HTTP_HOST} !^www\. 
RewriteRule^https://www.%{HTTP_HOST}%{REQUEST_URI} [NE,L,R] 
相關問題