![停止从 https 重定向到 http](https://linux22.com/image/1537446/%E5%81%9C%E6%AD%A2%E4%BB%8E%20https%20%E9%87%8D%E5%AE%9A%E5%90%91%E5%88%B0%20http.png)
我已在托管网站的 Centos 机器上启用了 SSL。但当我尝试访问该网站时,https://1.2.3.4
它会被重定向到http://1.2.3.4
。我该如何阻止这种行为?
我在 vhost.conf 文件中添加了以下内容
<Directory /var/www/html/example.com/public_html>
Require all granted
</Directory>
<VirtualHost *:80>
ServerName example.com
ServerAlias www.example.com
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html/example.com/public_html
ErrorLog /var/www/html/example.com/logs/error.log
CustomLog /var/www/html/example.com/logs/access.log combined
<Directory /var/www/html/example.com/public_html>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
</Directory>
</VirtualHost>
<VirtualHost *:443>
ServerName example.com
ServerAlias www.example.com
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html/example.com/public_html
ErrorLog /var/www/html/example.com/logs/error.log
CustomLog /var/www/html/example.com/logs/access.log combined
<Directory /var/www/html/example.com/public_html>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
</Directory>
</VirtualHost>
我也尝试在 ssl.conf 文件中添加类似内容<VirtualHost _default_:443>
。但它只是重定向到 http。我怎样才能阻止它从 https 重定向到 http。
我有一台不同的机器,它可以正常工作,并且具有与这台机器类似的配置。