【问题标题】:How can I redirect requests to php file extensions to aspx 404如何将请求重定向到 php 文件扩展名到 aspx 404
【发布时间】:2010-12-23 17:27:48
【问题描述】:

现在我正在将我的网站迁移到使用 IIS7 的新服务器,但我遇到了 404 错误页面的问题。

现在 www.example.com/missing 和 www.example.com/missing.aspx 转到我的 404.aspx 页面,但类似于 www.example.com/missing.php 或 www.example.com/missing .asdfasdf 返回 IIS7 404 错误页面。

我希望返回我自己的 404 错误页面而不是 IIS7 错误页面,但我不知道该怎么做。

【问题讨论】:

  • 您解决了这个问题吗?我的回答有帮助吗?
  • @Kev - 不,此设置已存在于配置文件中:(
  • 您能否将web.config 文件的相关部分粘贴到<customErrors><httpErrors>。您是在经典还是集成管道模式下运行?

标签: iis-7 http-status-code-404


【解决方案1】:

为您的web.config 配置以下内容:

<configuration>
    <system.webServer>
        <httpErrors existingResponse="PassThrough">
            <remove statusCode="404" subStatusCode="-1" />
            <error statusCode="404" prefixLanguageFilePath="" 
                   path="/404.aspx" responseMode="ExecuteURL" />
        </httpErrors>
    </system.webServer>
</configuration>

【讨论】:

  • 我们终于打开了开关,将我们的 DNS 指向了新服务器。对于其他遇到此问题的人来说,这是关键。如果您在本地服务器上,无论如何都会显示 IIS7 错误页面。但是相同的 URL 可以正常工作。谢谢你的帮助凯夫!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-12-31
  • 1970-01-01
  • 1970-01-01
  • 2010-12-11
  • 1970-01-01
相关资源
最近更新 更多