<IfModule mod_ssl.c>
<VirtualHost _default_:443>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
ServerName 68.183.182.49
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
SSLEngine on
SSLCertificateFile /etc/ssl/certificate.crt
SSLCertificateKeyFile /etc/ssl/private.key
SSLCertificateChainFile /etc/ssl/ca_bundle.crt
<FilesMatch "\.(?:cgi|shtml|phtml|php)$">
SSLOptions +StdEnvVars
</FilesMatch>
<Directory /usr/lib/cgi-bin>
SSLOptions +StdEnvVars
</Directory>
</VirtualHost>
如何让我的 DOMAIN:PORT 网站流量从 HTTP 切换到 HTTPS?上面的代码是我在 default-ssl.conf 文件中完成的代码。请大家帮忙。谢谢。
答案1
要在 Apache 中将 HTTP 重定向到 HTTPS,您可以将以下代码添加到 Apache 配置文件(通常为default.conf
)中,用于 HTTP 端口(通常为端口 80):
<VirtualHost *:80>
ServerName 68.183.182.49
Redirect / https://68.183.182.49
</VirtualHost>