我想将网站重定向到https://但我不希望重定向子域名。当我键入:dev.mycreditstatus.co.za时,它会被重定向到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}
我应该做些什么修改才能使这个工作?谢谢!
答案 0 :(得分: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]