ISAPI重写:在重写的URl的查询字符串中附加查询字符串

时间:2015-06-09 08:42:48

标签: isapi-rewrite

实际上,使用以下ISAPI规则

RewriteCond %{HTTP:Host} ^domain.com$
RewriteRule ^/Product-name/$ /test.cfm?ProductID=xxxx [NC,L]

我正在重写以下网址

htttp://www.domain.com/Product-name/

htttp://www.domain.com/test.cfm?ProducID=xxxx

这工作正常,但是当我在URL中使用查询字符串时,它无法正常工作

对于Egs: 以下网址无效

htttp://www.domain.com/Product-name?categoryID=YYYY

我需要按如下方式重写上述网址

htttp://www.domain.com/test.cfm?ProducID=xxxx&categoryID=YYYY

我使用了以下规则,但没有运气

RewriteCond %{QUERY_STRING} ^param=(\d+)$ [NC] 
RewriteRule ^/Product-name/$ /test.cfm?ProductID=xxxx?param2=%1? [NC,L]

那么有什么解决办法吗?

2 个答案:

答案 0 :(得分:0)

如果您正在使用ISAPI_Rewrite 3,那么您应该添加QSA标志以将原始查询字符串附加到生成的URL:

RewriteRule ^/Product-name/$ /test.cfm?ProductID=xxxx [NC,L,QSA]

答案 1 :(得分:0)

以下规则将查询字符串附加到重写的URL的Querystring并避免404错误

使用查询字符串和尾随斜杠(/)的网址

RewriteRule ^/Product-name/\? /test.cfm?ProductID=xxxx [NC,L,QSA]

使用查询字符串且没有尾随斜杠的网址(/)

RewriteRule ^/Product-name\? /test.cfm?ProductID=xxxx [NC,L,QSA]

没有查询字符串且带有尾部斜杠的网址(/)

RewriteRule ^/Product-name/$ /test.cfm?ProductID=xxxx [NC,L]

没有查询字符串和尾随斜杠的网址(/)

RewriteRule ^/Product-name$ /test.cfm?ProductID=xxxx [NC,L]