Ask Learn
Preview
Please sign in to use this experience.
Sign inThis browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
在进行如下带静态文件的自定义404页面配置时,
您可能会收到如下错误(见下图),
500.19 - Internal Server Error
Absolute physical path "driver:\path" is not allowed in system.webServer/httpErrors section in web.config file. Use relative path instead.
根本原因:
当在web.config文件中检测到绝对路径时,就会产生此错误。
目前针对该问题有2种解决方案。
方案1:
<system.webServer> ... <httpErrors allowAbsolutePathsWhenDelegated="true"> <error statusCode="401" prefixLanguageFilePath="%SystemDrive%\inetpub\custerr" path="401.htm" /> <error statusCode="403" prefixLanguageFilePath="%SystemDrive%\inetpub\custerr" path="403.htm" /> <error statusCode="404" prefixLanguageFilePath="%SystemDrive%\inetpub\custerr" path="404.htm" /> <error statusCode="405" prefixLanguageFilePath="%SystemDrive%\inetpub\custerr" path="405.htm" /> .... </httpErrors> </system.webServer> </location> <location path="Default Web Site"> <system.webServer> ... ... <httpErrors errorMode="Custom"> <remove statusCode="404" subStatusCode="-1" /> <error statusCode="404" prefixLanguageFilePath="" path="E:\Temp\custom404.html" responseMode="File" /> </httpErrors> </system.webServer> </location> |
方案2
1. 在IIS Manager中,找到Features Views->Management Area,双击"Feature Delegation"。选择Error Pages并单击Read Only,如下图。
2. 在C:\inetpub\wwwroot或您的任何网页应用程序的物理目录下,打开web.config文件,移除以下部分。
<handlers accessPolicy="Read, Script" /> <httpErrors> <remove statusCode="404" subStatusCode="-1" /> <error statusCode="404" prefixLanguageFilePath="" path=" E:\Temp\error404.html " responseMode="File" /> </httpErrors> |
如果在config文件中没有其他配置,您可以直接删除由IIS为delegation Read/Write生成的web.config文件。
3. 重启IIS。
更多信息
如何在IIS7中进行自定义404页面设置。您能通过以下步骤达到该目的:
参考
HTTP Errors <httpErrors>
https://www.iis.net/ConfigReference/system.webServer/httpErrors
谢谢!
微软 Internet 开发者支持小组
Please sign in to use this experience.
Sign in