在IIS 7中为HTML页面设置自定义404页面

时间:2012-04-27 06:42:24

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

我的网站是.htm扩展名,服务器是IIS 7.我现在设计了自定义404页面。

现在有人可以建议我,如何通过web.config实现自定义404页面。

2 个答案:

答案 0 :(得分:12)

我在IIS7中的.htm页面也遇到了同样的问题(不是ASP,不是.NET)。

我在responseMode中将File更改为ExecuteURL而不是<system.webServer>,一切正常:

<httpErrors errorMode="Custom" existingResponse="Replace">
    <remove statusCode="404" />
    <error statusCode="404" responseMode="File" path="error.htm" />
</httpErrors> 

答案 1 :(得分:5)

web.config文件中使用此功能:

<httpErrors errorMode="Custom" existingResponse="Replace">
    <remove statusCode="404" />
    <error statusCode="404" responseMode="ExecuteURL" path="/Errors/NotFound" />
</httpErrors>