Lamtha2 Logo
01296 768182

Web Design

Ecommerce

SEO Marketing

Our Work

1and1’s custom error 404 pages

1and1 shared hosting allows website owners to have custom error pages. The only problem is they expect you to use html pages. Read on to find out why html error pages are no a good idea and what you can do about it. 

If a site visitor reaches your site via an incorrect or obsolete url, you need to serve an error page to them. This is not only helpful to the site visitor but it also tells search engines that the page doesn’t exist and that they can remove it from their index. Don’t think that leaving obsolete urls in the search engine results provides an additional way into yor site; what it is actually doing is cluttering up the search engines and they might just penalise your ranking.

So you want to tell the search engines about removed pages. To do this you need to serve an error page. 1and1 do provide a default error 404 page but it will have no mention of your site so the vistor will likely move on and you’ll lose them. So you should serve them a custom 404 page.

This is where there is a problem with 1and1. 1and1 servers are set up to a serve custom error404.html page.

Why you need a PHP error page

To create a error404 page correctly it must return a server response of 404 ‘page not found’. A html page will return a 200 response which tells the search engines that this is a valid url which is not what you want.

To return the correct error response the error page must be a PHP page with the following code included:

<?php
header(“HTTP/1.0 404 Not Found”);
?>

Now you would expect that you’d simply have to edit your .htaccess to point to the new error404.php file as follows:

ErrorDocument 404 /error404.php

The problem is that 1and1 shared hosting servers are setup by default to serve a error404.html page not a error404.php.

So this change to your .htaccess wont work.

Instead if you want to get a custom error404.php page to work on 1and1 shared hosting you need to add the following rewriterule to your .htaccess:

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) /error404.php