HTTPS网站需要Htaccess帮助



所以我卡住了

我有一个重定向端口80流量重定向到https版本的网站。所有的网站都在https上

RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.domain.com/$1 [R=301,L]

所有页面重定向到正确的https版本。

现在我想把域名改为dom-ain.com,但我被困在如何重定向到这个新的https域名可能不是https。

我有反向链接到非https版本和https版本的domain.com

如果我希望网站现在重定向到新域名,并且我计划保持它在结构和内容上的精确副本,那么htaccess代码应该是什么

您可以使用:

RewriteEngine on 
RewriteCond %{HTTP_HOST} domain.com$ [NC,OR]
RewriteCond %{HTTPS} off
RewriteRule ^ https://www.dom-ain.com%{REQUEST_URI} [NE,L,R=301]

在新域为https之前,使用:

RewriteEngine on 
RewriteCond %{HTTP_HOST} domain.com$ [NC,OR]
RewriteCond %{HTTPS} on
RewriteRule ^ http://www.dom-ain.com%{REQUEST_URI} [NE,L,R=301]

最新更新