重定向到不同的URL与舱口类似参数 [英] Redirecting to different url with similar parameters in hatches
问题描述
我想重定向以下字符串 productdetails.asp PID = 23&安培; CID = 1 要么 productdetails.asp PID = 23&安培; CID = 3 PID可以是任何号码,我有以下几点:
I want to redirect the following strings productdetails.asp?pid=23&cid=1 or productdetails.asp?pid=23&cid=3 pid could be any number I have the following:
RewriteCond %{QUERY_STRING} ^pid=([0-9]+)&cid=1?
RewriteRule ^productdetails\.asp$ /Compare/Roland-Digital-Pianos? [L,NC,R=301]
RewriteCond %{QUERY_STRING} ^pid=([0-9]+)&cid=3?
RewriteRule ^productdetails\.asp$ /Compare/Kawai-Digital-Pianos? [L,NC,R=301]
但由于某些原因,当CID = 3仍改写为/比较/罗兰数字,钢琴 同时,我希望它去比较/河合数字,钢琴 任何帮助欢迎
but for some reason when cid=3 it still rewrites to /Compare/Roland-Digital-Pianos while i want it to go to Compare/Kawai-Digital-Pianos Any help Welcome
推荐答案
这是因为放错位置的?
在重写条件。在正则表达式?
使previous组选它做 1
或 3
在您的查询字符串的选项。
That is because of misplaced ?
in your rewrite condition. In regex ?
makes previous group optional which is making 1
or 3
option in your query string.
使用这些规则来代替:
RewriteCond %{QUERY_STRING} ^pid=([0-9]+)&cid=1(&|$) [NC]
RewriteRule ^productdetails\.asp$ /Compare/Roland-Digital-Pianos? [L,NC,R=301]
RewriteCond %{QUERY_STRING} ^pid=([0-9]+)&cid=3(&|$) [NC]
RewriteRule ^productdetails\.asp$ /Compare/Kawai-Digital-Pianos? [L,NC,R=301]
这篇关于重定向到不同的URL与舱口类似参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!