重定向根目录但不重定向子文件夹

Ant*_*one 3 .htaccess redirect url-redirection

我只想将我的网站 www.example.com 的根重定向到 www.example2.com 而不是子文件夹 www.example.com/subfolder !是否可以?

EG 以下规则重定向我的所有网站:

Redirect 301 / http://www.example2.com
Run Code Online (Sandbox Code Playgroud)

sta*_*een 6

要仅重定向根,您可以使用以下命令

RedirectMatch 301 ^/$ http://example2.com/
Run Code Online (Sandbox Code Playgroud)