将一个干净的url重定向到另一个问题


Redirecting one clean url to another issue

我正在尝试将example.com/en/**Weight_Loss-p370**重定向到example.com/en/**Weight_Loss-c145**,因为第一个是第二个的重复页。

我尝试过很多东西,但例如,当我在.htaccess:中添加这一行时

Redirect 301 /en/Weight_Loss-p370 http://example.com/en/Weight_Loss-c145

我得到:example.com/en/Weight_Loss-c145?sys_lang=en&elem_id=370

某些参数从无到有。

知道怎么解决这个问题吗?感谢

这是由于在执行此规则之前其他规则正在更改REQUEST_URI。

您可以将此规则用作您的第一条规则

RewriteEngine On
# specific URLs
RewriteRule ^(en/Weight_Loss)-p370/?$ /$1-c145? [L,NC,R=301]
# remaining URLs
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . http://siteB.com/? [L,R=301]

请确保在测试之前清除浏览器缓存。