1

我的虚拟主机配置文件看起来像这样

<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 时,它可以正常工作。

谢谢你的帮助

4

1 回答 1

0

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

于 2013-05-08T09:17:40.863 回答