我有这个示例规则:
RewriteRule ^stories\/([0-9]+)\/(.*)+ stories/index.cfm?id=$1
这工作完美。
现在,我会redirect一个页面(只是重新编写)到另一个:
Redirect 301 /stories/2000/title-of-stories http://host/stories/2001/another-stories
但是Apacheredirect到
http://host/stories/2001/another-stories?id=2000
追加到URL的查询string“?id = 2000”
我如何删除它?
非常感谢!
你的问题是RewriteRule在redirect之后被应用。
最佳做法是不要混合来自mod_rewrite(RewriteRule)和mod_alias(redirect)的指令。 它们的应用顺序不是基于您编写规则的顺序,而是根据模块加载的顺序。
在这种情况下,用等价的RewriteRulereplaceRedirect 301指令将是最好的select。 我没有testing过,但是这样的东西可能适合你。 请注意,你应该把你最具体的规则:
RewriteRule ^ / stories / 2000 / title-of-stories $ / stories / 2001 / another-stories [L,R = 301] RewriteRule ^ / stories /([0-9] +)/(。*)+ /stories/index.cfm?id=$1 [L]