子域名重定向到www

时间:2018-07-27 07:51:45

标签: apache virtualhost

我在apache配置中为一个子域设置了两个虚拟主机。一种用于SSL,另一种用于非SSL重定向到SSL。就是这样:

<VirtualHost *:80>
    ServerName subdomain.domain.tld

    Redirect permanent / https://subdomain.domain.tld/
</VirtualHost>
<VirtualHost *:443>
    DocumentRoot "/var/www/subdomain"
    ServerName subdomain.domain.de

    <Directory "/var/www/subdomain">
            AllowOverride All
            allow from all
            Options +Indexes
    </Directory>

    SSLCertificateFile /etc/letsencrypt/live/subdomain.domain.tld/fullchain.pem
    SSLCertificateKeyFile /etc/letsencrypt/live/subdomain.domain.tld/privkey.pem
    Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>

显然,我也使用“加密”。

DNS的设置如下:

subdomain.domain.tld IN A <IP address of server>

问题是,在我的浏览器中对subdomain.domain.tld的任何请求最终都将重定向到https://www.subdomain.domain.tld

该设置甚至不包含对www的任何请求。

为什么将我的请求重定向到www?这就是我要避免的事情。

1 个答案:

答案 0 :(得分:0)

我找到了问题。

它与apache配置无关,而是托管的worpress实例进行了301重定向。

对不起。

相关问题