Apache Redirect 正在重定向所有 HTTP,而不仅仅是一个子域

Apache Redirect 正在重定向所有 HTTP,而不仅仅是一个子域

所有 HTTP 请求(例如http://example.com)都会重定向到https://redmine.example.com,但我只希望http://redmine.example.com被重定向。

000-default我的配置中有以下内容:

<VirtualHost *:80>
        ServerName redmine.example.com
        DocumentRoot /usr/share/redmine/public

        Redirect permanent / https://redmine.example.com
</VirtualHost>

<VirtualHost *:80>
        ServerAdmin webmaster@localhost

        DocumentRoot /var/www
        <Directory />
                Options FollowSymLinks
                AllowOverride None
        </Directory>
        <Directory /var/www/>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride None
                Order allow,deny
                allow from all
        </Directory>
        .
        .
        .
</VirtualHost>

这是我的default-ssl配置:

<VirtualHost *:443>
        ServerName redmine.example.com
        DocumentRoot /usr/share/redmine/public

        SSLEngine on
        SSLCertificateFile    /etc/ssl/certs/ssl-cert-snakeoil.pem
        SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key

        BrowserMatch "MSIE [2-6]" \
                nokeepalive ssl-unclean-shutdown \
                downgrade-1.0 force-response-1.0
        BrowserMatch "MSIE [17-9]" ssl-unclean-shutdown

        <Directory /usr/share/redmine/public>
                Options FollowSymLinks
                AllowOverride None
                Order allow,deny
                Allow from all
        </Directory>

        LogLevel info
        ErrorLog /var/log/apache2/redmine-error.log
        CustomLog /var/log/apache2/redmine-access.log combined
</VirtualHost>

<VirtualHost *:443>
        ServerAdmin webmaster@localhost

        DocumentRoot /var/www
        <Directory />
                Options FollowSymLinks
                AllowOverride None
        </Directory>
        <Directory /var/www/>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride None
                Order allow,deny
                allow from all
        </Directory>
        .
        .
        .
</VirtualHost>

这里是否存在导致所有 HTTP 请求被重定向到的因素https://redmine.example.com

答案1

ServerName你的第二个中没有<VirtualHost *:80>;没有它,任何请求都不会映射到该虚拟主机。

如果您希望它成为所有未发送请求的默认值redmine.example.com,则请将 redmine vhost 放在文件中的默认 vhost 下方。

相关内容