2017-06-14 203 views
2

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

我搜索了一会儿发现,我们可以使用下面启用双编码:

<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> 

例如, 对于URL:/测试/测试+页

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

有没有办法解决这个从所请求的URL来捕捉,使URL参数p1将有test+page(原件)的值?

+0

您需要更改规则以允许“+”。这个替换早在它到达CF服务器之前就已经发生了。 –

+0

我已经在'^ test /([\ - a-z0-9 _。+] +)$“'模式中允许”+“。 – Beginner

回答

0

您可以使用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>