【问题标题】:IIS Mod-Rewrite QUERY_STRING/QSA problemsIIS Mod-Rewrite QUERY_STRING/QSA 问题
【发布时间】:2011-10-21 08:22:39
【问题描述】:

我们使用 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]

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

谢谢!

【问题讨论】:

    标签: iis mod-rewrite


    【解决方案1】:

    除了查询字符串附加,我什至不确定你的重写规则是否有效?!?我建议使用这样的东西:

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

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

    【讨论】:

    • 感谢您的回复马可。事实证明,添加 QSA 一直有效,但其他代码导致了问题!也感谢 NC 提示...
    猜你喜欢
    • 2023-03-05
    • 1970-01-01
    • 1970-01-01
    • 2012-07-25
    • 1970-01-01
    • 2011-02-04
    • 2010-12-06
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多