.htaccess 将子文件夹重定向到子域时htaccess重定向问题

.htaccess 将子文件夹重定向到子域时htaccess重定向问题,.htaccess,mod-rewrite,redirect,.htaccess,Mod Rewrite,Redirect,我需要使用htaccess将子文件夹重定向到子域 我需要重定向 example.com/test 到 我有以下规则 RewriteEngine On RewriteCond %{HTTP_HOST} ^(?:www\.)?example\.com$ [NC] RewriteRule ^test/?$ https://user.example.com/test [R=301,L] 重新启动发动机 重写cond%{HTTP_HOST}^(?:www\)?示例\.com$[NC] 重

我需要使用htaccess将子文件夹重定向到子域

我需要重定向

example.com/test

我有以下规则

RewriteEngine On RewriteCond %{HTTP_HOST} ^(?:www\.)?example\.com$ [NC] RewriteRule ^test/?$ https://user.example.com/test [R=301,L] 重新启动发动机 重写cond%{HTTP_HOST}^(?:www\)?示例\.com$[NC] 重写规则^test/?$https://user.example.com/test [R=301,L] 如何修改此规则以满足上述条件?

您可以使用:

RewriteEngine On

RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} !^user\.example\.com$ [NC]
RewriteRule ^test/?$ https://user.example.com/test [R=301,L,NC,NE]

在新浏览器中测试此项,以避免旧缓存。

此外,我需要重定向到,也需要重定向user.example.com/Test到此规则已满足所有这些条件。让我知道哪个没有。你能修改给定的规则以同时满足example.com/test、http:example.com/test、https:example.com/test、,和user.example.com/test到https:user.example.com/test是否要我将您提供的规则添加到htaccess中现有规则的下面?此规则应替换您的现有规则,并应位于
RewriteEngine
行的正下方。如果删除现有规则,我将错过从www.example.com/test重定向到https:user.example.com/test的过程