我在日志中注意到以下错误:
Exception Type:
System.Web.HttpException
Exception: A potentially dangerous Request.Path value was detected from the client (:).
Stack Trace:
at System.Web.HttpRequest.ValidateInputIfRequiredByConfig() at System.Web.HttpApplication.PipelineStepManager.ValidateHelper(HttpContext context)
这种情况发生在URL的末尾,这可能是由电子邮件软件引起的,该软件在以表示的电子邮件中包含冒号,“我的网站位于www.someurl.com:找到信息”。。
我想将每个以冒号结尾的URL重写并重定向到相同的URL,而冒号不在最后一个位置。
这就是我所拥有的:我在web.config中添加的条目
<system.webServer>
<rewrite>
<rules>
<rule name="Rewrite without last colon">
<match url="[:]\z" /> //not sure this is correct
<action type="Rewrite" url="not sure what to put" />
</rule>
</rules>
</rewrite>
</system.webServer>
答案 0 :(得分:1)
您可以尝试使用此重写规则。
<rule name="Remove colon" stopProcessing="true">
<match url="(.*):$" />
<action type="Rewrite" url="{R:1}" />
</rule>
(.*) = everything before the :
$ = end of the string to be matched
参考
https://ruslany.net/2009/04/10-url-rewriting-tips-and-tricks/