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

时间:2017-02-27 18:42:11

标签: .htaccess redirect url-redirection

我想将我的网站www.example.com的根目录重定向到www.example2.com 但不是子文件夹www.example.com/subfolder! 有可能吗?

E.G。 以下规则重定向我的所有网站:

Redirect 301 / http://www.example2.com

1 个答案:

答案 0 :(得分:2)

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

RedirectMatch 301 ^/$ http://example2.com/