Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set up custom 404 page in IIS 7 for HTML pages

I have my website in .htm extension and the server is IIS 7. I have now design custom 404 page.

Now can anyone suggest me, how to implement custom 404 page by web.config.

like image 340
royalmayur Avatar asked Apr 27 '12 06:04

royalmayur


2 Answers

Use this in your web.config file:

<httpErrors errorMode="Custom" existingResponse="Replace">
    <remove statusCode="404" />
    <error statusCode="404" responseMode="ExecuteURL" path="/Errors/NotFound" />
</httpErrors>
like image 36
Vishnu Arunachalam Avatar answered Oct 05 '22 03:10

Vishnu Arunachalam


I too was having the same problem with .htm pages in IIS7 (not ASP, not .NET).

I changed responseMode to File instead of ExecuteURL in <system.webServer> and everything worked:

<httpErrors errorMode="Custom" existingResponse="Replace">
    <remove statusCode="404" />
    <error statusCode="404" responseMode="File" path="error.htm" />
</httpErrors> 
like image 83
kamchatka Avatar answered Oct 05 '22 01:10

kamchatka