asp.net - IIS 重定向正则表达式不适用于空格 - URL 中的 %20

标签 asp.net iis-7 web-config url-rewrite-module url-redirection

所以我有一个简单的问题,但不知何故似乎不起作用。我有一个 URL http://www.domain.com/%20#axzz2ZX4J0KAS,我想将其重定向到 http://www.domain.com/page-name.htm。我在 IIS URL Rewrite/web.config 中尝试了很多组合,它们似乎都可以在测试模式对话框中工作,但在浏览器中都不起作用。

1.

<rule name="Redirect%20InHomePage" enabled="true" stopProcessing="true">
    <match url="^(.+)domain\.com/(\s|%20)(.+)" ignoreCase="true" />
    <action type="Redirect" url="http://www.domain.com/page-name.htm" />
</rule>

2.

   <match url="(.+)/%20(.+)" ignoreCase="true" />

3.

    <match url="(.+)domain.com/ (.+)" ignoreCase="true" />

4.

   <match url="(.+)domain.com/(\s|%20)(.+)" ignoreCase="true" />

如您所见,我尝试了上述所有模式,它们在测试模式对话框中都运行良好,但当我浏览 URL 时,它总是将 %20 转换为空格,并且规则不适用于重定向。

如果有人知道我错过了什么,请帮助我解决这个简单但尚未解决的问题。

最佳答案

我遇到了类似的问题,通过为我的规则输入空格“”而不是 %20 来让它工作。

所以在这里你可能想为你的空间尝试 [ ]。

http://imgur.com/6sjWVjL

关于asp.net - IIS 重定向正则表达式不适用于空格 - URL 中的 %20,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17756957/

相关文章:

c# - asp.net 未找到 OpenCV 非托管 DLL

windows - 自动将 http 重定向到 https - web.config - Plesk 12.0.18 for Windows

c# - 是否可以将 web.config 中的位置授权节点设为外部?

asp.net - Request() 与 Request.QueryString()

javascript - 选择列表项值不适用于 Javascript asp mvc

python - Django + IIS +?

javascript - 替换多个链接的硬编码 anchor 部分

c# - 使用 ClientBuildManager.CompileFile 就地编译

asp.net-mvc - xdt :Transform ="Insert" not working for <rewrite> in <system. 网络服务器>

c# - 在另一个用户控件中使用一个用户控件的自定义事件?