IIS Mod 重写 QUERY_STRING/QSA 问题
我们使用 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-工具/?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]
建议将不胜感激(因为它让我发疯!)
谢谢!
We use IIS Mod-Rewrite from MicoNovae for our IIS rewrites on Windows 2003.
We use the RewriteRule command, for example:
http://www.site.com/section35/page1/tiling-tools/
becomes:
http://www.site.com/search.asp?section=35&page=1&model=tiling-tools
I now have a situation where I need to append the querystring to the re-written URL, for example:
http://www.site.com/section35/page1/tiling-tools/?myid=dskajh34kjhsvkjh34
need to become
http://www.site.com/search.asp?section=35&page=1&model=tiling-tools&myid=dskajh34kjhsvkjh34
My rules are:
RewriteEngine On
RewriteRule /\.htaccess$ - [F]
RewriteRule ^/section([^/]+)/page([^/]+)/?([^/]*)/?([^/]*)/?([^/]*)/$ /search_results.asp?section=$1&page=$2&model=$3 [L]
I've tried the following, without success:
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]
Suggestions will be appreciated ('cos it's driving me mad!)
Thank you!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
除了附加的查询字符串之外,我什至不确定您的重写规则是否有效?!?我建议使用这样的内容:
NC 标志使您的重写规则不区分大小写,而 QSA 标志添加您需要的查询字符串。
Apart from the query string appending, I'm not even sure your rewrite rule is working at all?!? I would suggest to use something like this:
The NC flag makes your rewrite rule non-case sensitive and the QSA flag adds the query string you need.