How to Redirect your 404 error to a Custom Page
A 404 error message is the standard HTTP standard response code which is returned when the visitor cannot communicate with the server. Visitor gets a standardized undesirable 404 Error Page
This is a very common error on the web and it occurs when you are trying to visit a page which has either been deleted or has been moved somewhere else.
For example, if you change the structure of your website and move a certain directory to a different part of your site, anyone trying to visit the old page url will get a 404 error message.
404 Error Messages
A 404 error is pretty much lost traffic with in your website. You have managed to get the visitor there with your SEO efforts but a changed page over site results in the visitor getting the generic server 404 error messages. A lot of standard 404 messages are useless and do not even refer your visitor back to the homepage. A 404 error message usually looks something like this :
The requested URL /index.php was not found on this server.
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
Apache/2.2.9 (Unix) mod_ssl/2.2.9 OpenSSL/0.9.7a mod_bwlimited/1.4 PHP/5.2.6 Server at yourwebsite.com Port 80
Example of Windows Internet Explorer 10 404 Error Message – 404 Error Page
404 Error Message Reality
If a visitor comes to your site and sees a standard 404 error message it’s unlikely they will make the effort to see any part of your site. Therefore it is very important to create a 404 page on your site and redirect traffic from incorrect urls.
Thankfully, htaccess makes this very easy. First of all you need to create a 404 error page. So for example, you would create a page at http://www.yoursite.com/404.php which says something like :
It appears you are looking for something which isn’t there. Either you have entered an incorrect URL or we have messed up. Why not visit our home page or alternatively, search for what you are looking for in the search box below.
Whilst a 404 error page does not send the visitor to the exact page they want, it can be used for a better presentation of your website. Offering the visitor other page options, alternate choice to go back and generally point them in the right direction is better than them leaving ASAP.
The 404 .htaccess error page keeps them on your site pages so that they are more likely to stay and find what they want on your site.
htaccess 404 Error Code
Once you have your 404 page setup, all you need to do is send visitors of incorrect url’s to this page. To do this just add the following line to your .htaccess file :
ErrorDocument 404 /404.php
Most often, the .htaccess file will be in the home root public_html folder on your server. This can change, for an example if you run you site or blog out of a specific folder within the public_html.
Alternately, You can place the 404 error template anywhere you want in a folder. For example you could place all error messages in a folder called errormessages refererring the 404 error to the url of the page.
ErrorDocument 404 /errormessages/404.php
That’s all there is to it.
Now when a visitor views an incorrect url on your site they will see your custom 404 error message.
404 Error Messages Comments
Don’t have 404 error handling system? Set up a .htaccess file with quick ErrorDocument 404 code link sending your visitor back to the index home page. When you have more time code a custom 404 error page with the information you want.
ErrorDocument 404 /index.html Adjust code to reflect your home page file name: / “to your index page” You can test if 404 error redirect is working by going to a page within your site, url other than home page, type in a few junk characters in the addresses file box name .. and if 404error working browser sends you or you visitor to the home page. Good quick temporary fix!
Page Errors Adsense: If your operating your sites with Google(R) Adsense, you probably seen a larger focus on page errors in your account with any crawler errors listing of your bad site(s) page . Users don’t like 404 page errors as it decreases the user experience. Do a little revenue optimization and site health by solving page errors one by one … best use a 301 redirect for each page error in your htaccess file
404 error Reference, Notes, Tips
A 404 error is classified page as “Not found” or non existent url. A 410 error is a “Gone” response code.
HTTP response code 404 tells both browsers and search engines that your page doesn’t exist. Page content and ranking position will be lost, neither the page be crawled or indexed, by your top Google, Bing or Yahoo search engines.