【问题标题】:Apache redirect .net, .org, .co to .com using Rewrite or serveraliasApache 使用 Rewrite 或 serveralias 将 .net、.org、.co 重定向到 .com
【发布时间】:2012-08-14 05:02:59
【问题描述】:

我有一个网站。我为我的网站购买了所有 (mydomain.com|net|org|co) 域名。现在,我想将所有请求重定向到 mydomain.com。目前,在我的 httpd.conf 中,我有将 http 请求转发到 https 的重写规则。

For forwarding all http requests to https
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) @987654321@{HTTP_HOST}%{REQUEST_URI}

我将现有设置与this answer 结合起来,并尝试了以下代码:
RewriteEngine on
RewriteCond %{HTTPS} off
RewriteRule (.*) @987654323@{HTTP_HOST}%{REQUEST_URI}
RewriteCond %{HTTP_HOST} !^example.org$
RewriteRule ^ http://example.org%{REQUEST_URI} [L,R=301]

它适用于 http 请求,但不适用于 https(https://mydomain.net/info)。我获得了mydomain.com 的 SSL 证书。它正在向我显示此连接不受信任页面。

处理这种情况的最佳方法是什么。有人可以指导我吗

提前致谢,
死人。

【问题讨论】:

    标签: apache mod-rewrite


    【解决方案1】:

    试试这个:

    RewriteEngine on
    RewriteCond %{HTTPS} off
    RewriteRule (.*) https://example.com%{REQUEST_URI}
    RewriteCond %{HTTP_HOST} !^example.com$
    RewriteRule ^ http://example.com%{REQUEST_URI} [L,R=301] 
    

    【讨论】:

    • 我试过上面的代码。我有 SSL 证书 mydomain.com。当我使用你的规则时,mydomain.net 向我抛出不受信任的连接而不是重定向。
    猜你喜欢
    • 2018-09-05
    • 2018-11-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-03-28
    • 2011-05-06
    • 1970-01-01
    相关资源
    最近更新 更多