实际上,使用以下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]
那么有什么解决办法吗?
答案 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]