IIS Mod-重写QUERY_STRING / QSA问题

时间:2011-10-21 08:22:39

标签: iis mod-rewrite

我们使用MicoNovae的IIS Mod-Rewrite在Windows 2003上重写IIS。

我们使用RewriteRule命令,例如: http://www.site.com/section35/page1/tiling-tools/ 变为: http://www.site.com/search.asp?section=35&page=1&model=tiling-tools

我现在遇到需要将查询字符串附加到重写URL的情况,例如: http://www.site.com/section35/page1/tiling-tools/?myid=dskajh34kjhsvkjh34 需要成为 http://www.site.com/search.asp?section=35&page=1&model=tiling-tools&myid=dskajh34kjhsvkjh34

我的规则是:

RewriteEngine On
RewriteRule /\.htaccess$ - [F]
RewriteRule ^/section([^/]+)/page([^/]+)/?([^/]*)/?([^/]*)/?([^/]*)/$ /search_results.asp?section=$1&page=$2&model=$3 [L]

我尝试了以下内容,但没有成功:

RewriteRule ^/section([^/]+)/page([^/]+)/?([^/]*)/?([^/]*)/?([^/]*)/$ /search_results.asp?section=$1&page=$2&model=$3&%{QUERY_STRING} [L]

RewriteRule ^/section([^/]+)/page([^/]+)/?([^/]*)/?([^/]*)/?([^/]*)/$ /search_results.asp?section=$1&page=$2&model=$3 [L,QSA]

建议将不胜感激('因为它让我发疯!)

谢谢!

1 个答案:

答案 0 :(得分:1)

除了附加查询字符串之外,我甚至不确定你的重写规则是否正常工作?!?我建议使用这样的东西:

RewriteRule ^/section([0-9]+)/page([0-9]+)/(.*)/    /search_results.asp?section=$1&page=$2&model=$3    [NC,L,QSA]

NC标志使您的重写规则不区分大小写,QSA标志会添加您需要的查询字符串。