使用mod_rewrite仅重定向主页

Bre*_*all 3 apache .htaccess mod-rewrite redirect

我有一个需要重定向的网站,但我不能只重定向/目录,因为服务器上的文件夹中还有其他网站,并且这样做也会重定向它们.不好!

所以我的.htaccess文件有一堆301重定向用于单独的HTML页面,这些工作正常.但我需要重定向主页.这是我必须做的:

RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_HOST} ^recherchegoldens.com [NC]
RewriteRule ^(.*)$ http://whitegoldenretriever.com/$1 [R=301,L]
Run Code Online (Sandbox Code Playgroud)

转发主页,很棒.但它也搞砸了我的其他301重定向.这是我的重定向之一:

Redirect 301 /Available-Pups.html http://www.whitegoldenretriever.com/available-pups/
Run Code Online (Sandbox Code Playgroud)

但是根据上面的重写规则,如果我输入recherchgoldens.com/Available-Pups.html,它只是转发给whitegoldenretriever.com/Available-Pups.html

但我不希望这样.我希望它仍然转发到我的Redirect 301指令中设置的位置.

我究竟做错了什么?

anu*_*ava 6

要仅重定向主页,请使用:

RewriteCond %{HTTP_HOST} ^recherchegoldens\.com$ [NC]
RewriteRule ^/?$ http://whitegoldenretriever.com/ [R=301,L]
Run Code Online (Sandbox Code Playgroud)

确保在新浏览器中对此进行测试,以避免旧的浏览器缓存.