繁体   English   中英

IIS重写模块-URL末尾的编码空间,查找用于重定向页面的重写规则

[英]IIS rewrite module - Encoded space at end of URL, looking for a rewrite rule to redirect the page

我有一个讨厌的小问题。 我正在将MVC 3与重写模块一起使用。 从另一个网站链接到我的网站的链接为:

hxxp:www.mysite.com/%20

也就是说,其他网站广告在其网址末尾添加%20(编码的空格字符)。

现在,我需要将此链接重定向到主站点,如下所示:

hxxp://www.mysite.com/

否则会产生404 not found错误。

现在的问题,我尝试了不同的重写规则,但是似乎没有任何东西可以重定向网站,例如

<rule name="redirect space" stopProcessing="true">
          <match url="^hxxp://www.mysite.com/%20" />
          <action type="Redirect" url="hxxp://www.mysite.com/" redirectType="Permanent" />
        </rule>

和许多其他组合,但似乎无法解决,并且在每种情况下都会产生404错误。

尝试为该空间添加一些变体:编码的一个,解码的和一个空格字符,如下所示:

<rule name="redirect space" stopProcessing="true">
  <match url="^hxxp://www.mysite.com/((%20)|\ |\s)+" />
  <action type="Redirect" url="hxxp://www.mysite.com/" redirectType="Permanent" />
</rule>

更多信息可以在这里找到:

如果仍然无法使用,则必须编写自己的rewite模块。 您可以在这里看到更多详细信息:

用C#.net web.config中的-替换Url中的%20

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM