QUERY_STRING重写订单

时间:2017-07-03 20:15:57

标签: mod-rewrite url-rewriting url-redirection

我有以下重写规则,它们会重写到同一个位置:

http://test.com/finance/payroll/forms/salary-payment-form.shtml?staff=test-edu-trust - > TO - > https://www.test.com/finance/BBBB.shtml?staff=test-edu-trust

RewriteRule %{QUERY_STRING} ^staff=test-edu-trust$
RewriteRule ^/finance/payroll/forms/salary-payment-form.shtml$ https://www.test.com/finance/BBBB.shtml?staff=test-edu-trust[R=301,L,NC]

http://test.com/finance/payroll/forms/wages-payment-form.shtml?staff=test-comm-rac - > TO - > https://www.test.com/finance/BBBB.shtml?staff=test-comm-rac

RewriteRule %{QUERY_STRING} ^staff=test-comm-rac$
RewriteRule ^/finance/payroll/forms/salary-payment-form.shtml$ https://www.test.com/finance/BBBB.shtml?staff=test-comm-rac[R=301,L,NC]

问题是重写到同一位置 - https://www.test.com/finance/BBBB.shtml?staff=test-edu-trust

如果我将规则的顺序更改为以下,则他们最终会按顺序重写到第一个位置:https://www.test.com/finance/BBBB.shtml?staff=test-comm-rac,如下所示:

RewriteRule %{QUERY_STRING} ^staff=test-comm-rac$
RewriteRule ^/finance/payroll/forms/salary-payment-form.shtml$ https://www.test.com/finance/BBBB.shtml?staff=test-comm-rac[R=301,L,NC]

RewriteRule %{QUERY_STRING} ^staff=test-edu-trust$
RewriteRule ^/finance/payroll/forms/salary-payment-form.shtml$ https://www.test.com/finance/BBBB.shtml?staff=test-edu-trust[R=301,L,NC]

这里导致规则顺序的原因只是重写为第一个定义的,因为我认为QUERY_STRING会抓住这个并将哪个url重写为??

1 个答案:

答案 0 :(得分:0)

注意到我有RevingRule而不是RewriteCond用于QUERY_STRING !! Doh !!!