如果网址中有https
,我无法从一个域重定向到另一个域。
也就是说,我必须处理在域http://www.mywebsite1.net
上发出的所有请求,这些请求必须重新绑定到域https://www.mywebsite2.com
通过这个代码,我可以通过htaccess安全地管理它:
RewriteEngine on
RewriteRule ^(.*)$ https://www.mywebsite2.com/$1 [R=301,L]
问题是如果网址带有此https://www.mywebsite1.net
错误页面
NET :: ERR_CERT_COMMON_NAME_INVALID
因为旧域上不再安装SSL证书。那么我该如何处理这个问题呢?
我希望我足够清楚。 谢谢
答案 0 :(得分:0)
查看SNI,服务器名称指示。如果浏览器支持它,您可以根据需要创建VHost(详细信息:https://wiki.apache.org/httpd/NameBasedSSLVHostsWithSNI)
# Ensure that Apache listens on port 443
Listen 443
# Listen for virtual host requests on all IP addresses
NameVirtualHost *:443
# Go ahead and accept connections for these vhosts
# from non-SNI clients
SSLStrictSNIVHostCheck off
<VirtualHost *:443>
# Because this virtual host is defined first, it will
# be used as the default if the hostname is not received
# in the SSL handshake, e.g. if the browser doesn't support
# SNI.
DocumentRoot /www/example1
ServerName www.mywebsite1.net
# Other directives here
</VirtualHost>
<VirtualHost *:443>
DocumentRoot /www/example2
ServerName www.mywebsite2.com
# Other directives here
</VirtualHost>
所有现代浏览器都支持此功能。如果他们不这样做,那么你就会陷入困境,因为HTTP-Header Part已加密,因此无法及早选择正确的vhost。