2014-02-12 34 views
2

我想將網站重定向到https://但我不希望子域名被重定向。當我輸入:dev.mycreditstatus.co.za時,即使我不希望它被重定向到https://。如何防止子域名重定向到https

下面是我的.htaccess(public_ssl)目前的代碼:

ErrorDocument 404 https://mycreditstatus.co.za/404.php 

Options +FollowSymLinks -MultiViews 
# Turn mod_rewrite on 
RewriteEngine On 

RewriteCond %{HTTPS} on 
RewriteCond %{HTTP_HOST} ^imupost\.co\.za$ [NC] 
RewriteRule^http://%{HTTP_HOST}%{REQUEST_URI} [R=301,L] 

的.htaccess(的public_html):

ErrorDocument 404 https://mycreditstatus.co.za/404.php 

RewriteEngine On 
RewriteCond %{HTTPS} off 
RewriteCond %{REQUEST_URI} !^/(pp5fdr) [NC] 
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} 

我做什麼修改,得到這個工作?謝謝!

回答

5

在您的public_html .htaccess中,您沒有任何條件將其僅限於主域(這假定您的子域位於同一目錄中)。您需要另一個RewriteCond以僅匹配主域:

ErrorDocument 404 https://mycreditstatus.co.za/404.php 

RewriteEngine On 
RewriteCond %{HTTPS} off 
# Only redirect to https if the main domain (no subdomain) is matched 
# case-insensitively in HTTP_HOST 
RewriteCond %{HTTP_HOST} ^mycreditstatus\.co\.za$ [NC] 
RewriteCond %{REQUEST_URI} !^/(php05142013) [NC] 
# added flags... 
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] 
+0

哇。非常感謝。我是新來的正則表達式和國防部重寫,所以我不知道該怎麼把.htaccess。再次感謝您幫助我。 – maikelsabido