将多个 subfolders/subdirectory 重定向到一个域

Redirect multiple subfolders/subdirectory to one domain

所以我想知道是否可以使用 htaccess 将多个子目录重定向到另一个域。

现状:

理想的重定向:

我阅读了一些关于 Apache 及其语法的知识,但我离完全理解它还很远。它似乎使用正则表达式,但没有使用'|' (或).

网站主机指示如下编写htaccess,其中example.nl/webshop重定向到example.com/shop:

Redirect 301 /webshop http://www.example.com/shop

但我需要它来重定向多个(但不是全部)子目录。是否可以使用正则表达式,如果可以,如何使用?如果无法重定向多个子目录,有哪些替代方案?

提前致谢!

您可以使用 mod-rewrite 重定向您的网址。在您的 htaccess 文件中尝试以下操作:

RewriteEngine on

#redirect the specified lang paths to another domain
RewriteRule ^(nl|fr|en|it|es)/ https://example2.com%{REQUEST_URI} [NE,L,R=301]