如何重定向到SSL和www除子域名

时间:2017-08-02 05:54:50

标签: mod-rewrite

我有example.com,我希望所有请求到达:https://www.example.com

我也有subdomain.example.com,我希望所有这些请求都到达https://subdomain.example.com

1 个答案:

答案 0 :(得分:0)

需要更多输入。你用apache?

然后像:

<VirtualHost *:80>
    ServerName subdomain.example.com
    RewriteEngine On
    RewriteRule (.*) https://subdomain.example.com/$1 [R,L] 
</VirtualHost>

<VirtualHost *:*>
    ServerName example.com
    RewriteEngine On
    RewriteRule (.*) https://www.example.com/$1 [R,L] 
</VirtualHost>