Custom 404's can be set for ASP and .NET sites by adding the following code to the bottom of the web.config file before the final </configuration>. You will need both options to redirect all 404's.
Classic ASP and Static Content
<configuration>
<system.webServer>
<httpErrors errorMode="DetailedLocalOnly" defaultPath="/404.asp" defaultResponseMode="ExecuteURL">
<remove statusCode="404" subStatusCode="-1" />
<error statusCode="404" prefixLanguageFilePath="" path="/404.html" responseMode="ExecuteURL" />
</httpErrors>
</system.webServer>
</configuration>
.NET
<configuration>
<system.web>
<customErrors defaultRedirect="404.aspx" mode="DetailedLocalOnly">
<error statusCode="404" redirect="404.aspx"/>
</customErrors>
</system.web>
</configuration>
This exampled shows 404's for all content redirecting to index.html:
<configuration>
<system.webServer>
<httpErrors errorMode="DetailedLocalOnly" defaultPath="/index.html" defaultResponseMode="ExecuteURL">
<remove statusCode="404" subStatusCode="-1" />
<error statusCode="404" prefixLanguageFilePath="" path="/index.html" responseMode="ExecuteURL" />
</httpErrors>
</system.webServer>
<system.web>
<customErrors mode="On">
<error statusCode="404" redirect="/index.html" />
</customErrors>
</system.web>
</configuration>
© 2011-2013 Rackspace US, Inc.
Except where otherwise noted, content on this site is licensed under a Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported License

0 Comments
Add new comment