Apache .htaccess-重定向到特定页面+;重定向到/

Apache .htaccess-重定向到特定页面+;重定向到/,apache,.htaccess,mod-rewrite,Apache,.htaccess,Mod Rewrite,我试图为我的网站写一个像样的.htaccess,但没有成功 我的问题是,我只想将某个页面重定向到另一个域的另一个页面。所有其他请求必须重定向到/other域 为了更清楚,我举一个例子: 我只想重定向: www.foo.com/test_a.php => www.bar.com/newcategory/newpage www.foo.com/another_page.php => www.bar.com/anothernewcategory/anothernewpage 所有其他请求

我试图为我的网站写一个像样的.htaccess,但没有成功

我的问题是,我只想将某个页面重定向到另一个域的另一个页面。所有其他请求必须重定向到/other域

为了更清楚,我举一个例子:

我只想重定向:

www.foo.com/test_a.php => www.bar.com/newcategory/newpage
www.foo.com/another_page.php => www.bar.com/anothernewcategory/anothernewpage
所有其他请求必须重定向到www.bar.com

例如:

www.foo.com/some_another_page_not_listed_above => www.bar.com
这是我的.htaccess,但它不起作用:

RewriteEngine On

RewriteCond %{HTTP_HOST} ^/test_a.php
RewriteRule www.bar.com/newcategory/newpage/ [NC,L,R=301]

RewriteCond %{HTTP_HOST} ^/another_page.php 
RewriteRule www.bar.com/anothernewcategory/anothernewpage/ [NC,L,R=301]

RewriteCond %{HTTP_HOST} ^/  
RewriteRule https://www.bar.com/ [L,R=301]

规则1和2起作用。规则3否。例如,如果我进入www.foo.com/test_页面,我不会被重定向


我哪里错了?你能试试这个吗

RewriteEngine On
RewriteRule  ^test_a.php http://www.bar.com/newcategory/newpage/ [NC,L,R=301]
RewriteRule ^another_page.php http://www.bar.com/anothernewcategory/anothernewpage/ [NC,L,R=301]
RewriteRule ^ https://bar.com [L,R=301]

@西蒙妮·朱斯蒂:对不起,请重试我上面的.htaccess。它现在应该可以工作了。@SimoneGiusti:我测试了我上面编辑的那个,它工作得非常好。请尝试一下,让我知道它仍然无法工作。@SimoneGiusti:我还发布了你的real.htaccess,更正后再次测试:)