Custom 404 Files, using ASP or .Net
A Blog from Mike Irving, Software Developer
By Mike Irving - Published: 22/7/2008
Many web developers setup Custom 404 Files on their Websites to present a user-friendly alternative to the browser's own "File Not Found" page, however we can do a whole lot more when we start scripting within our 404 file.
We can perform 301 Redirects from old page names, to new ones, useful for SEO purposes.
We can serve a non-physical robots.txt file dependant on the HOST name. this is useful if your web server serves your site on multiple domains. You will only want Google and Search Engines to crawl one of the domains, to avoid duplicate content issues, so using the 404 page we can deliver either a Spiderable Robots file, or otherwise, dependant on the domain.
We would chnage the page Content Type to "text/plain" and the Status Code to "200" / OK in or robots.txt case.
We can also use the 404 file for simple URL Rewriting. A list of URL Rewrites can be handled in the 404 file, and a page can be delivered for each, as desired. In this case, we would change the page Status code to 200/OK on delivery, as opposed to 404/Not Found.
All of the above can be achieved easily using ASP or ASP.Net, or indeed any other scripting language.
You will need to setup the Custom 404 functionality on your web server, or with your hosting company. This can either be done direct in IIS, or is usually a setting available in your Web Hosting provider's control panel.
Page Not Found files can offer much more than meets the eye!
View Blog Entries...
Page: 1, 2, 3, 4, 5, 6, 7, 8