htaccess 301将匹配字符串重定向到另一个域url


htaccess 301 redirect of matching string to another domain url

Am试图将域a的url重定向到域b,其中重定向是为了适应域b的最佳url

例如,要进行301重定向的域A。

http://www.abc.com/blog/
http://www.abc.com/old-games?view=pages&layout=sell

博客旁边有很多pgaes,在旧游戏等下有很多页面作为子url。

域B

http://www.xyz.com/index.php?option=com_blog&view=entry&Itemid=5
http://www.xyz.com/index.php?option=com_forms&view=pages&layout=sellgames&Itemid=10

尝试过以下htaccess重定向条件

RewriteCond %{REQUEST_URI} ^.*/blog.*$
RewriteRule .*   http://www.xyz.com/index.php?option=com_blog&view=entry&Itemid=5 [R=301,L]
RewriteCond %{REQUEST_URI} ^.*/old-games.*$
RewriteRule .*  http://www.xyz.com/index.php?option=com_forms&view=pages&layout=sellgames&Itemid=10 [R=301,L]

重定向发生在上

 http://www.xyz.com/index.php as tested using http://htaccess.madewithlove.be/

Pl建议最好的方法,就好像在上面遗漏了什么一样

感谢

用以下代码替换您的代码:

RewriteRule ^blog(/|$) http://www.xyz.com/index.php?option=com_blog&view=entry&Itemid=5 [R=301,L,QSA,NC]
RewriteRule ^old-games(/|$) http://www.xyz.com/index.php?option=com_forms&view=pages&layout=sellgames&Itemid=10 [R=301,L,NC,QSA]

请确保在其他浏览器中进行测试或清除浏览器缓存。