Mod rewrite 重写中间路径的重写规则

Mod rewrite 重写中间路径的重写规则,mod-rewrite,Mod Rewrite,我需要编写一个重写规则的代码,以便来自以下方面的文章: www.olddomain.com/categoryA/categoryB/article.html 被重定向到: www.newdomain.com/categoryC/categoryD/article.html 因此这里的挑战是article.html页面不会从一个站点更改到另一个站点,但中间路径(类别)是不同的。 我已尝试编写此规则: RewriteRule ^(categoryA/categoryB/.+)$ http://w

我需要编写一个重写规则的代码,以便来自以下方面的文章:

www.olddomain.com/categoryA/categoryB/article.html
被重定向到:

www.newdomain.com/categoryC/categoryD/article.html
因此这里的挑战是article.html页面不会从一个站点更改到另一个站点,但中间路径(类别)是不同的。 我已尝试编写此规则:

RewriteRule ^(categoryA/categoryB/.+)$ http://www.newdomain.com/categoryC/categoryD/$1 [L,NC,R=301,NE]
但是,该规则从以下位置重定向:

http://www.olddomain.com/categoryA/categoryB/article.html

在执行重定向时,您能给我建议一种排除“旧”类别的方法吗?我希望被重定向到:

http://www.newdomain.com/categoryC/categoryD/article.html
非常感谢

就这么简单:

RewriteRule ^categoryA/categoryB/([^/]+)\.html$ http://www.newdomain.com/categoryC/categoryD/$1.html [R=301,L,NC,NE]
RewriteRule ^categoryA/categoryB/([^/]+)\.html$ http://www.newdomain.com/categoryC/categoryD/$1.html [R=301,L,NC,NE]