【问题标题】:Error redirect domain with https to another domain使用 https 将域重定向到另一个域时出错
【发布时间】:2018-03-06 13:44:32
【问题描述】:

如果网址中有https,我无法从一个域重定向到另一个域。

也就是说,我必须处理在域 http://www.mywebsite1.net 上发出的所有请求,这些请求必须重新回到域 https://www.mywebsite2.com

有了这个,我通过 htaccess 使用以下代码安全地管理它:

RewriteEngine on   
RewriteRule ^(.*)$ https://www.mywebsite2.com/$1 [R=301,L]

问题是,如果一个 url 带有这个 https://www.mywebsite1.net 错误页面

NET :: ERR_CERT_COMMON_NAME_INVALID

因为 SSL 证书不再安装在旧域上。那么我该如何处理这个问题呢?

我希望我已经足够清楚了。 谢谢

【问题讨论】:

    标签: apache .htaccess ssl redirect apache2


    【解决方案1】:

    查看 SNI,服务器名称指示。如果浏览器支持,您可以根据需要创建VHosts(详情: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 部分是加密的,所以没有办法足够早地选择正确的虚拟主机。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-04-01
      • 1970-01-01
      • 2020-06-02
      • 1970-01-01
      • 1970-01-01
      • 2015-12-15
      • 2020-05-04
      • 2019-08-13
      相关资源
      最近更新 更多