我已在托管网站的 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。
我有一台不同的机器,它可以正常工作,并且具有与这台机器类似的配置。