apache vhosts https / ssl子域总是重定向到主非https页面

时间:2013-05-07 17:23:23

标签: apache redirect ssl https vhosts

我的vhosts配置文件如下所示

<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时,它没有任何问题。

感谢您的帮助

1 个答案:

答案 0 :(得分:0)

你应该在documentroot中有一个.htaccess,或者是一个基于HTTP_HOST的脚本重定向