【问题标题】:Redirect sub domain A to https domain B将子域A重定向到https域B
【发布时间】:2018-08-31 16:35:31
【问题描述】:

我已尝试寻找与我的问题相关的帖子,但找不到合适的帖子。如果有,请告诉我!

这是我现在面临的现状。我想重定向一个域,

example.hr

它正在与另一台服务器一起使用,并且附带一个 SSL。

现在,我有另一个域附带的服务器,

example.co

还有一个 SSL 证书。

我想将 test.example.hr 重定向到 https://example.co。我该怎么做呢?由于使用了根域,因此我正在使用子域对其进行测试。

这个方法我试过了,

<VirtualHost *:80>
        ServerName test.example.hr
        ServerAlias www.test.example.hr
        Redirect / https://example.co/
</VirtualHost>


<VirtualHost *:443>
    ServerName example.co
    ServerAlias www.example.co
    DocumentRoot /var/www/html
    ErrorLog /var/www/html/error.log
    CustomLog /var/www/html/access.log combined
</VirtualHost>

SSL 配置在 443 块内。

当我转到 test.example.hr 时,它会更改为 https://test.example.hr 并且出现的错误是“您的连接不是私有的。攻击者可能试图从 test.alt.hr 窃取您的信息(例如例如,密码、消息或信用卡)。了解更多 NET::ERR_CERT_COMMON_NAME_INVALID"

【问题讨论】:

    标签: apache ssl redirect url-redirection


    【解决方案1】:

    你可以试试这个并更新我。

    <VirtualHost *:80>
            ServerName test.example.hr
            ServerAlias www.test.example.hr
            Redirect / http://example.co/
    
            RewriteEngine On
            RewriteCond %{HTTPS} off
            RewriteRule (.*) https://%{SERVER_NAME}/$1 [R,L]
            </VirtualHost>
    
    
    <VirtualHost *:443>
        ServerName example.co
        ServerAlias www.example.co
        DocumentRoot /var/www/html
        ErrorLog /var/www/html/error.log
        CustomLog /var/www/html/access.log combined
    </VirtualHost>
    

    确保启用a2enmod rewrite

    【讨论】:

    • 它现在重定向但在地址栏上显示“不安全”,因为它与 SSL 证书 example.co 不匹配
    • 它必须重定向 example.co 。您是否正在尝试一些通配符重定向,即https://*.example.co?如果是这样,您的证书中也应该有一个通配符。
    猜你喜欢
    • 2017-03-23
    • 1970-01-01
    • 2018-06-07
    • 2016-01-30
    • 1970-01-01
    • 2019-02-21
    • 1970-01-01
    • 1970-01-01
    • 2018-06-01
    相关资源
    最近更新 更多