【问题标题】:apache vhosts https/ssl subdomain always redirected to main non-https pageapache vhosts https/ssl 子域始终重定向到非 https 主页面
【发布时间】:2013-05-01 18:11:17
【问题描述】:

我的虚拟主机配置文件如下所示

<VirtualHost *:443>
    ServerName api.example.com
    DocumentRoot /var/www/example.com/live/api/
    <Directory /var/www/example.com/live/api/>
     Options FollowSymLinks
     AllowOverride All
     Order allow,deny
     allow from all
    </Directory>

    SSLEngine on
    SSLCertificateFile /etc/ssl/certs/mycert.pem
    SSLCertificateKeyFile /etc/ssl/private/mycert.key
</VirtualHost>

<VirtualHost *:80>
ServerName example.com
ServerAlias www.example.com
DocumentRoot /var/www/example.com/live/
<Directory /var/www/example.com/live/>
Options FollowSymLinks
AllowOverride All
Order allow,deny
allow from all
</Directory>
ErrorLog /var/log/apache2/error-example.com-live.log
LogLevel warn
CustomLog /var/log/apache2/access.log combined
</VirtualHost>

只要我尝试访问https://api.example.com,我就会被重定向到http://www.example.com。 当我将文档根目录更改为 /var/www/whatever-but-not-used-by-other-vhost 时,它可以正常工作。

感谢您的帮助

【问题讨论】:

    标签: apache redirect ssl https vhosts


    【解决方案1】:

    您应该在 documentroot 中有一个 .htaccess,或者由基于 HTTP_HOST 的脚本进行重定向

    【讨论】:

    • 谢谢。我在两个文档根目录中都有一个 .htaccess,但是无论我输入什么,我都会被重定向到 http://www.example.com。如果我将 CustomLog 添加到第一个虚拟主机,它会记录 301 重定向,但我不知道它来自哪里。
    猜你喜欢
    • 1970-01-01
    • 2017-07-04
    • 1970-01-01
    • 2019-04-12
    • 2011-05-01
    • 2014-10-02
    • 2018-06-02
    • 2019-12-17
    • 1970-01-01
    相关资源
    最近更新 更多