简体   繁体   English

apache vhosts https / ssl子域始终重定向到主要的非https页面

[英]apache vhosts https/ssl subdomain always redirected to main non-https page

my vhosts configuration file looks like this 我的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>

as soon as I try to access https://api.example.com I get redirected to http://www.example.com . 尝试访问https://api.example.com时,我立即重定向到http://www.example.com When I change the document root to /var/www/whatever-but-not-used-by-other-vhost it is working without any problems. 当我将文档根目录更改为/ var / www / whatever-but-not-used-by-other-vhost时,它可以正常工作。

Thanks for your help 谢谢你的帮助

您应该在文档根目录中有一个.htaccess或由基于HTTP_HOST的脚本进行的重定向

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM