Custom 404 page in IIS 7 – 500.19


You may receive 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.


 



 


when configure Custom 404 page with static file as below.




 


Root Cause


========


 


The error is generated due to an absolute path is detected in web.config.


 


There are 2 ways to fix the issue.


 


Solution 1


=========


1.    Set allowAbsolutePathsWhenDelegated attribute ‘true’ at <system.webServer> <httpErrors> in ApplicationHost.config.


 







<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" />


       <error statusCode="406" prefixLanguageFilePath="%SystemDrive%\inetpub\custerr" path="406.htm" />


       <error statusCode="412" prefixLanguageFilePath="%SystemDrive%\inetpub\custerr" path="412.htm" />


       <error statusCode="500" prefixLanguageFilePath="%SystemDrive%\inetpub\custerr" path="500.htm" />


       <error statusCode="501" prefixLanguageFilePath="%SystemDrive%\inetpub\custerr" path="501.htm" />


       <error statusCode="502" prefixLanguageFilePath="%SystemDrive%\inetpub\custerr" path="502.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 reset


 


Solution 2


========


 


1.    In IIS manager, double click “Feature Delegation” in Management Area in Features Views. Choose Error Pages and click Read Only, as below.


 


 


 


2.    Open web.config under C:\inetpub\wwwroot folder or your web application’s physical folder, remove following sections. If there is no other setting in the web.config file, you may delete this web.config that was created by IIS for above delegation Read/Write setting.


 







<handlers accessPolicy="Read, Script" />


        <httpErrors>


            <remove statusCode="404" subStatusCode="-1" />


            <error statusCode="404" prefixLanguageFilePath="" path=" E:\Temp\error404.html " responseMode="File" />


</httpErrors>


 


3.    IIS Reset


 


More information


==============


How to setup custom 404 page in IIS 7. You can do it by following steps:


1.    Create a custom404.html file and save the file in your Web folder (typically c:\inetpub\wwwroot).


2.      Open Internet Information Services (IIS) Manager.


3.    In the Connections pane (on the left), expand the tree to the Web site for which you want to set up custom errors, and then select that Web site.


4.    Click Features View at the bottom of the middle pane.


5.    Double-click Error Pages in the middle pane.


6.    Double-click Status Code 404.


7.    In the Edit Custom Error Page dialog box,


7.1 Type the physical path to “Insert content from static file into the error response” field. When page cannot be found happen, it returns http 404 and display custom 404 page.


7.2 Type the absolute path to “Exectute a URL on this site” field, for this example, type /custom404.html. When page cannot be found happens, it returns http 200 and display custom 404 page.



 


8.    Click Ok.


Reference


========


HTTP Errors <httpErrors>


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


 


Regards,


 


Anik Shen


 

Comments (1)

  1. Michael says:

    Thanks for sharing this, it was of help to me. Just so you know if you just specify "error404.html" it will look in the root directory of the website, so you don't need an absolute path unless you're wanting to sharing the same html file across websites.

Skip to main content