【发布时间】:2020-12-13 01:32:53
【问题描述】:
我有一个域名为 example.info 的网站。最近我获得了两个新域名:example.com 和 example.org。
我在 example.info 上有一个 SSL 证书,我将所有 http 重定向到 https,如下所示:
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
现在我希望 example.com 成为主要 url,另外两个我只想重定向到 example.com。
我将 SSL 证书从 .info 更改为 .com,一切都很好,但我的问题是,例如 Google 从 https://example.info 链接我,现在它失败了,因为该 url 没有 SSL 证书了。所以我想做的是将https://example.info重定向到https://example.com。
我尝试了不同的方法,但这是不起作用的解决方案之一。
RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_URI} !^(www\.)?example\.info$
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{HTTPS} on
RewriteCond %{HTTP_HOST} ^(www\.)?example\.info$
RewriteRule ^ https://example\.com [L,R=301]
我做错了什么?如何实现将 https://example.info 重定向到 https://example.com 并保持重定向到 https for example.com?
//// 编辑
如果我因为没有有效证书而无法重定向https://example.info,如何防止在我写http://example.info 时它被重定向到https?
【问题讨论】:
-
如果
https://example.info没有有效的 ssl 证书,则无法重定向。 -
谢谢。那么当你不想再拥有证书时有什么解决方案吗?
标签: .htaccess mod-rewrite