【问题标题】:Double escaping along with URL rewrite in IISIIS 中的双重转义和 URL 重写
【发布时间】:2017-06-14 09:16:52
【问题描述】:

我有一个 URL(自动生成),它的路径中有加号(+),我得到了 404。

我搜索了一段时间发现我们可以使用以下方式启用双重编码:

<security>
  <requestFiltering allowDoubleEscaping="true" />
</security>

我面临的问题是该 URL 的重写规则,在捕获的组中加号被替换为空格:

<rule name="Test Page Rewrite" stopProcessing="true">
    <match url="^test/([\-a-z0-9_.+]+)$" ignoreCase="true" />
    <conditions>
        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
    </conditions>
    <action type="Rewrite" url="test/index.cfm?p1={R:1}" />
</rule>

例如, 对于网址:/test/test+page

页面上可用的URL参数是p1: test page

是否有任何解决方法可以从请求的 URL 中捕获,以便 URL 参数 p1 的值为 test+page(original)?

【问题讨论】:

  • 您需要更改规则以允许“+”。这种替换早在它到达 CF 服务器之前就已经发生了。
  • 我已经在^test/([\-a-z0-9_.+]+)$" 模式中允许了“+”。你还有别的意思吗?

标签: iis url-rewriting coldfusion iis-7.5


【解决方案1】:

您可以使用UrlEncode 函数。这条规则应该适合你:

<rule name="Test Page Rewrite" stopProcessing="true">
    <match url="^test/([\-a-z0-9_.+]+)$" ignoreCase="true" />
    <conditions>
        <add input="{REQUEST_URI}" pattern="^/test/index.cfm" negate="true" />
    </conditions>
    <action type="Rewrite" url="test/index.cfm?p1={UrlEncode:{R:1}}" />
</rule>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-05-23
    • 2018-12-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-11-04
    • 2016-06-27
    相关资源
    最近更新 更多