在类似的问题中解决了 here (Apache httpd.conf for redirecting ip to hostname)
我想知道如何通过 SSL 从 HTTPS 静态 ip 重定向到主机名。
我目前正在使用下面发布的配置,但是当我对其进行测试时,我收到了警告,实际上我必须在它重定向之前单击“继续访问站点”。我尝试删除 SSLEngine on
段,但它不会完全连接。
Listen 443
<VirtualHost *:443>
ServerName 192.168.1.1 #Not the actual IP of server
ServerAlias 192.168.1.1 #Not the actual IP of server
SSLEngine on
SSLCertificateFile /var/ssl/website/cert.crt
SSLCertificateKeyFile /var/ssl/website/privkey.key
RewriteEngine On
RewriteCond %{HTTP_HOST} !^website.com$
RewriteRule /.* https://website.com/ [R]
</VirtualHost>
知道需要做什么来避免必须单击“继续访问站点”以允许其重定向吗?
最佳答案
要从某个 https 站点重定向到任何其他站点,您需要拥有该站点的有效证书,即主题与 URL 中的名称匹配的证书。在您的情况下,证书可能不包含 IP 地址,这就是为什么访问该站点将导致证书验证错误,您已通过单击“继续访问站点”明确忽略了该错误。
关于Apache httpd.conf 用于将 ip 重定向到主机名 - SSL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39981890/