我需要为几千个不断更改的URL设置重定向。
从此 - example.com/product?product_id=blue_alwayschanging
至此 - example.com/widget?product_id=blue_alwayschanging
由于我的知识有限,我认为下面的内容是朝着正确方向迈出的一步。我错过了什么?它没有用。
RewriteEngine on
RedirectMatch 301 ^/product?product_id=blue_.* /widget?product_id=.*
答案 0 :(得分:1)
RewriteEngine
激活mod_rewrite。而RedirectMatch
是mod_alias指令。 RedirectMatch
也与查询字符串不匹配,但您不需要,因为查询字符串只需要不变地传递给目标。
尝试使用以下单行替换当前代码:
RedirectMatch 301 ^/product /widget