繁体   English   中英

使用.htaccess将HTTPS重定向到子域

[英]Redirecting HTTPS to Sub-Domain with .htaccess

我想将https://website.me/https://www.website.me/都重定向到https://es.website.me/


此规则不起作用

RewriteCond %{HTTPS} !^on$
RewriteRule (.*) https://es.website.me/$1 [R,L]

在htaccess下使用

RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www\.)?website\.me$ [NC]
RewriteRule ^(.*)$ https://es.website.me/$1 [R=301,L]

请尝试以下一种情况进行重定向:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^website.me$ [OR]
RewriteCond %{HTTP_HOST} ^www.website.me$
RewriteRule (.*)$ https://es.website.me/$1 [R=301,L]
</IfModule>

您要重定向还是重写?

要使用代码301(永久移动)进行重定向,请创建2个虚拟主机;否则,请转为2。 一个用于实际网站,另一个用于您要重定向的所有URL。 在重定向主机中,添加以下行:

Redirect 301 / https://es.website.me/

由于仅在已经使用HTTPS的情况下才想重定向,因此必须与主机名一起检查它。

RewriteCond %{HTTPS} on
RewriteCond %{HTTP_HOST} ^(www\.)?website\.me$ [NC]
RewriteRule ^ https://es.website.me%{REQUEST_URI} [R,L]

当一切正常运行时,可以将R替换为R=301 切勿使用R=301测试。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM