我的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时,它没有任何问题。
感谢您的帮助
答案 0 :(得分:0)
你应该在documentroot中有一个.htaccess,或者是一个基于HTTP_HOST的脚本重定向