[英]"+" character causing issues in IIS URL rewrite
I have the URL that I want to set a redirect to in IIS.我有 URL,我想在 IIS 中设置重定向。
Current URL: portal/en_us/apps/app+doc
New URL: apps/newapps
Not working with不与
<rule name="From portal/en_us/apps/app+doc" stopProcessing="true">
<match url="^portal/en_us/apps/app+doc$" ignoreCase="true" />
<action type="Redirect" url="https://domain1123.com/apps/newapps" />
</rule>
results in a 404 error导致 404 错误
Referring to a reference guide , we'll see that +
is defined as working like this:参考参考指南,我们会看到+
被定义为这样工作:
Matches previous element one or more times.匹配前一个元素一次或多次。
That means that this expression:这意味着这个表达式:
^portal/en_us/apps/app+doc$
Will match an entire string containing:将匹配包含以下内容的整个字符串:
And so on.等等。
To actually match a literal +
, you need to escape it using \
:要实际匹配文字+
,您需要使用\
将其转义:
^portal/en_us/apps/app\+doc$
Now it is treated as a literal +
and not interpreted as "one or more p characters".现在它被视为文字+
而不是解释为“一个或多个 p 字符”。
I have added allowDoubleEscaping我添加了 allowDoubleEscaping
<system.webServer>
<security>
<requestFiltering allowDoubleEscaping="true" />
</security>
</system.webServer>
You can try to encode the "+" character first, and then redirect.您可以尝试先对“+”字符进行编码,然后再重定向。
You can use this link to code: https://www.urlencoder.org .您可以使用此链接进行编码: https://www.urlencoder.org 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.