【问题标题】:redirect a domain with http to different domain with https使用 http 将域重定向到使用 https 的不同域
【发布时间】:2015-01-12 05:28:12
【问题描述】:

我有一个关于使用 http 将域重定向到使用 https 的不同域的问题。 我已经在我的域 www.some.com 上安装了 SSL 证书(它不是通配符,所以它仅适用于 www,并且在我的域中没有它),所以如果我继续 https://www.some.comhttp://www.some.com 一切正常,所有请求都被重定向到https://www.some.com

然后我购买了其他域,例如 test.org,所以如果我想将此域重定向到 https://some.com 浏览器提醒我 SSL 证书仅对 some.com 有效。

我插入的正确重写条件是:

RewriteCond %{HTTP_HOST} ^test\.org$ [OR]

RewriteCond %{HTTP_HOST} ^www\.test\.org$

RewriteRule ^/?$ "http\:\/\/some\.com\/" [R=301,L]

我该如何解决这个问题?

【问题讨论】:

  • 无需转义您要重定向到的 URL 中的字符。

标签: apache .htaccess mod-rewrite redirect ssl


【解决方案1】:

你可以使用它:

RewriteCond %{HTTP_HOST} ^(www\.)?test\.org$
RewriteRule ^/?$ http://some.com/ [R=301,L]

或带有所有最终 URL (test.org/xxxx/yyy...)

RewriteRule ^/?(.*)$ http://some.com/$1 [R=301,L]

但是,我真的不知道你的问题是什么,或者错误......

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-11-30
    • 2016-01-30
    • 1970-01-01
    • 2016-03-20
    • 2015-04-01
    • 1970-01-01
    • 2015-03-09
    • 2019-02-23
    相关资源
    最近更新 更多