IIS7中的自定义 404页面错误- 500.19

在进行如下带静态文件的自定义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:

    1. 在ApplicationHost.config文件中将<system.webServer> <httpErrors>的allowAbsolutePathsWhenDelegated设置为”true”。

<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. 重启IIS。

方案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页面设置。您能通过以下步骤达到该目的:

    1. 创建一个名为custom404.html的文件,并保存至您的网页目录(一般情况下为c:\inetpub\wwwroot)。
    2. 打开Internet Information Services (IIS) Manager。
    3. 在Connections窗口内(左边),展开相关节点至某个您想要进行自定义错误配置的站点,并选定该站点。
    4. 在中间窗口的底部,单击Features View。
    5. 在中间窗口,双击Error Pages。
    6. 双击Status Code 404。
    7. 在Edit Custom Error Page对话框中,
    a. 在”Insert content from static file into the error response”域中输入物理路径。当出现找不到页面的情况时,就会返回http 404错误并显示自定义的404错误页面。
    b. 在”Exectute a URL on this site”域中,输入绝对路径。在本实例中,输入/custom404.html。当出现找不到页面的情况时,就会返回http 200错误并显示自定义的404错误页面。

 

    8. 点击OK。

参考

 HTTP Errors <httpErrors>

http://www.iis.net/ConfigReference/system.webServer/httpErrors





评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值