【发布时间】:2018-11-25 04:40:18
【问题描述】:
我有一个托管多个网站的 apache 服务器:
main-website.com
subdomain1.main-website.com
subdomain2.main-website.com
another-website1.com
another-website2.com
another-website3.com
我只需要将https://www.main-website.com 重定向到https://www.main-website.com
子域和所有其他网站不需要 ssl 证书;因此我想通过指定只需要重定向主网站来将它们排除在重定向之外。
这是我的 .htaccess 语法(在这个主题上进行了大量研究似乎是正确的)
#NON-WWW to WWW (whis applies to all domains and subdomains)
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
#redirect HTTP to HTTPS only for main-website.com:
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} main-website.com [NC]
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
指定了重定向main-website.com的条件,但是不起作用!事实上,所有其他域和子域都被重定向到 HTTPS!
你知道错误可能在哪里吗?
谢谢你:)
【问题讨论】:
标签: apache .htaccess ssl redirect server