我有一个网站,有一个域名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,并保持example.com的https重定向?
/编辑
如果我因为没有有效的证书而无法重定向https,那么当我编写http://example.info时如何防止它被重定向到https?
发布于 2020-12-13 12:38:11
我认为你能做的最好的事情是:
RewriteCond %{HTTP_HOST} ^(www\.)?example\.(info|org)$
RewriteRule ^ https://example\.com%{REQUEST_URI} [L,R=301]
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
https://stackoverflow.com/questions/65271602
复制