将文件夹及其内容重定向到(无文件夹),同时保留 www 和 https


Redirect folder and its contents to (no folder) while keeping www and https

我有三个网站。每个都是一个文件夹,可访问如下:

example.com/siteA
example.com/siteB
example.com/siteC

类别和产品可能存在于这些网站中,例如:

example.com/siteA/category/subcategory/productABC

我在 3 个域下有 2 个新网址。

siteA = https://www.newsiteA.com
siteB = https://www.newsiteB.com
siteC = https://www.newsiteB.com/siteC

问题是将旧网址及其内容重定向到新网址,同时还使用 www 和 https 重定向。我无法让他们一起工作。

所需重定向的示例:

http://example.com/siteA/categoryA/*contents*
to
https://www.newsiteA.com/categoryB/*contents*

内容是该 URL 之后的任何内容。我一直在尝试通过htaccess(一个magento网站)进行尝试,但不介意通过另一种方法进行。非常感谢您的建议。

尝试将这些规则作为根 .htaccess 中的第一个规则:

RewriteEngine On
RewriteRule ^siteA(/.*)?$ https://www.newsiteA.com/$1 [L,NC,NE,R=301]
RewriteRule ^siteB(/.*)?$ https://www.newsiteB.com/$1 [L,NC,NE,R=301]
RewriteRule ^siteC(/.*)?$ https://www.newsiteC.com/$1 [L,NC,NE,R=301]