自定义404错误页面无法在IIS 8.5上运行 [英] Custom 404 error page not working on IIS 8.5
问题描述
我最近移动了主机,不得不在IIS中再次设置客户错误。
I have recently moved host and have had to set up Customer Errors again in IIS.
我可以按如下方式访问IIS管理员和错误页面:
I can go to IIS Admin and Error Pages as follows:
然后我可以转到自定义错误,并按如下方式设置选项:
Then I can go to the Custom Errors, and have set up the options as follows:
这会创建我的web.config文件,如下所示:
That creates my web.config file as follows:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<httpErrors errorMode="DetailedLocalOnly" defaultResponseMode="ExecuteURL">
<remove statusCode="500" subStatusCode="100" />
<remove statusCode="500" subStatusCode="-1" />
<remove statusCode="404" subStatusCode="-1" />
<error statusCode="404" prefixLanguageFilePath="" path="/error_404.asp" responseMode="ExecuteURL" />
<error statusCode="500" prefixLanguageFilePath="" path="/error_500.asp" responseMode="ExecuteURL" />
<error statusCode="500" subStatusCode="100" path="/error_500.asp" responseMode="ExecuteURL" />
</httpErrors>
</system.webServer>
</configuration>
当我测试页面时,505错误正常工作,并重定向到右页,但是404不重定向并返回标准IIS 404错误。我已确认服务器上的404错误页面位于正确的位置。
When I test the pages, the 505 error works fine, and redirects to the right page, but the 404 doesn't redirect and returns the standard IIS 404 error. I have confirmed that the 404 error page is in place on the server in the correct location.
我看不出还有什么需要做的。
I can't see what else I need to do.
推荐答案
最终让它发挥作用(帮助找到这个: http://forums.iis.net/t/1173965.aspx ),使用:
Got it working in the end (helped by finding this: http://forums.iis.net/t/1173965.aspx), using:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<httpErrors errorMode="Custom" defaultResponseMode="ExecuteURL">
<remove statusCode="500" subStatusCode="100" />
<remove statusCode="500" subStatusCode="-1" />
<remove statusCode="404" subStatusCode="-1" />
<error statusCode="404" path="/error_404.asp" responseMode="ExecuteURL" />
<error statusCode="500" prefixLanguageFilePath="" path="/error_500.asp" responseMode="ExecuteURL" />
<error statusCode="500" subStatusCode="100" path="/error_500.asp" responseMode="ExecuteURL" />
</httpErrors>
</system.webServer>
</configuration>
这篇关于自定义404错误页面无法在IIS 8.5上运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!