【问题标题】:Redirect to a Custom 404 Page When the URL ends with Dot当 URL 以点结尾时重定向到自定义 404 页面
【发布时间】:2017-03-12 01:06:47
【问题描述】:

在我的web.config 文件中,我将此规则用于重定向到自定义 404 页面,它适用于确实不存在的 URL。

<system.webServer>
    <httpErrors existingResponse="Auto" errorMode="Custom">
        <remove statusCode="404" subStatusCode="-1"/>
        <error statusCode="404" path="/CustomErrors.aspx" responseMode="ExecuteURL"/>
    </httpErrors>
</system.webServer>

我的问题在于以 Point(.) 字符结尾的 URL。例如

http://192.168.1.151/login.

或者

http://192.168.1.151/login....

这会导致以下错误:

“/”应用程序中的服务器错误。
找不到资源。

StackOverFlow 很好地处理了这个问题: 404 page in stackoverflow

任何建议都会有所帮助。

【问题讨论】:

标签: iis web-config http-status-code-404 custom-error-pages


【解决方案1】:

在 httpRuntime 部分添加此属性有帮助:

<configuration>
  <system.web>
    <httpRuntime ... relaxedUrlToFileSystemMapping="true" .../>
  </system.web>
</configuration>

获取或设置一个值,该值指示 HTTP 请求中的 URL 是否必须是有效的 Windows 文件路径。

更多关于relaxedUrlToFileSystemMapping的信息

【讨论】:

    猜你喜欢
    • 2012-10-01
    • 1970-01-01
    • 2015-08-01
    • 2016-11-21
    • 2014-12-23
    • 2019-09-14
    • 1970-01-01
    • 2015-10-10
    • 1970-01-01
    相关资源
    最近更新 更多