.htaccess的。将排除的子文件夹重定向到https版本的域,其他所有内容都会重定向到另一个域

问题描述 投票:0回答:1

我有一个多域网站,

这意味着根据域显示内容版本,

所以现在我有域chiname.comgreatwall.com当用户登陆chiname.com被重定向到https://www.greatwall.com除了两个文件夹/landing/marketing留在chiname.com但希望它在https版本的chiname.com

我尝试添加一个rewriteRule,但对我不起作用

RewriteEngine On
RewriteCond %{HTTP_HOST} ^chiname.com$ [NC]
RewriteCond %{REQUEST_URI} !^/(landing|marketing)
RewriteRule ^(landing/.*)$ https://www.chiname.com/$1 [R=301,L]
RewriteRule ^(marketing/.*)$ https://www.chiname.com/$1 [R=301,L]
RewriteRule ^(.*)$ https://www.greatwall.com/$1 [R=301,L]
php apache .htaccess vhosts
1个回答
0
投票

您可以使用这两个重定向规则:

RewriteEngine On

RewriteCond %{HTTPS} !on
RewriteCond %{HTTP_HOST} ^(?:www\.)?chiname\.com$ [NC]
RewriteRule ^(landing|marketing) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L,NC,NE]

RewriteCond %{HTTP_HOST} ^(?:www\.)?chiname\.com$ [NC]
RewriteCond %{REQUEST_URI} !^/(landing|marketing) [NC]
RewriteRule ^ https://www.greatwall.com%{REQUEST_URI} [R=301,L,NC,NE]

确保使用新的浏览器进行测试。

© www.soinside.com 2019 - 2024. All rights reserved.