Custom error pages on 1and1 when HTML files are set as PHP types

A long time ago I set up custom error pages on my 1&1 hosted websites. However recently I noticed that they had stopped working. When a 404 error occured, instead of redirecting to my error page I got an advert filled parking page.

1and1 error page

I re-checked their instructions for setting up the error pages on their FAQ and I was pretty sure that I was setting the pages up correctly.

After spending over an hour trying to figure out what was going wrong I stumbled on the ‘Empty Parking Pages’ link on the Domain Overview in their Administration control panel. You can see the position of this link in the red box.

1and1 admin page

On this page is the option to turn off their ‘Empty Parking Pages’. I turned this option off – it then took a few minutes for the change to be visible on my website.

1and1 empty pages parking

Part of the message says:

When using this service, a page from our webserver will be displayed instead. Unless, of course, you have set up your own error message.

Now instead of getting the advert filled parking page I got a plain:

Error 404 – Not found
Your browser can’t find the document corresponding to the URL you typed in.

It is better than before but it is still not my error message!

It seemed the only way I could get correctly working error files is to create files with the following file names in your site’s root directory – ‘error400.html’, ‘error403.html’, ‘error404.html’ and ‘error500.html’. No entry in the .htaccess file is needed – 1&1 automatically picks these files up as your error pages.

So why weren’t the ErrorDocument lines in my .htaccess working?

In my .htaccess file I also have the following line:
AddType x-mapp-php4 .html .htm

This line allows PHP code to be processed from .htm and .html files. If I remove this line then my ErrorDocument lines start working. It therefore seems that 1and1 have configured their servers so that you can only errors generated when you try to access static pages will cause the ErrorDocument directive to be used. Usually .html and .htm are static, however my AddType line in the .htaccess changed them into dynamic pages.

I removed .html from the AddType line. After doing this the ErrorDocument worked for .html files but not for .htm.

After all this I have deduced the following:

  1. If you want to get rid of the advert filled parking pages you need to use the control panel.
  2. If you configure your 1&1 .htaccess file to allow PHP in .htm and .html then the ErrorDocument line won’t work for any missing .htm or .html files. However the ErrorDocument will work for non-PHP files types.
  3. The ErrorDocument directive will never work for .php file types as these are always registered as being PHP types.
  4. The only way to get working error files for all types of errors is to create ‘error400.html’, ‘error403.html’, ‘error404.html’ and ‘error500.html’ files.

Final tip

In the 1&1 FAQ on creating error pages they give three suggestion for creating custom error pages:

  1. Using ErrorDocument in .htaccess (which only works for static document types).
  2. Adding the errorXXX.html error pages (which does work for all document types).
  3. Adding the below code to your .htaccess.

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) /errordocument.html

I would suggest that you don’t add this to your .htaccess! This redirects any 404 ‘not found’ errors to the errordocument.html webpage. This causes a 200 error code to be returned rather than a 404 error code. This is a bad idea as it could cause search engines to end up indexing all the error pages on your website.

18 Comments on “Custom error pages on 1and1 when HTML files are set as PHP types”

  1. Thanks for this post – I have just gone through exactly the same process and knew nothing about the empty pages parking option, thankfully it’s now off!

    The cheek of some hosting companies eh?

  2. It’s fairly irksome that 1and1 puts up a spam page on my site as an “exclusive” service. I uploaded an error404.html doc hoping that the server would parse my php code per the settings in my .htaccess file. Unfortunately, 1and1 passed the php code to my browser. At least the empty parking option is off. Thanks for the tip.

  3. Man, many, many thanks for this tip. This has been annoying me for ages, 1and1’s support could only suggest the “RewriteEngine On” option, without explaining what was occurring – and as you sugest this is not ideal for search engines etc. Anyway, thanks to your post i know whats going on and can fix it!

  4. Hallelujah!!!

    I skirted around for ages trying to work out what I had done wrong. Then I found this solution and everything fitted into place.

    Thank you sooooooo much.

  5. it will work better if you add this to your .htaccess

    #turn off the smart spelling matching feature.
    CheckSpelling off

    #set your real error document, which can be a php document.
    ErrorDocument 404 /404.shtml

    # check for missing files of types you can’t get to work automatically.
    RewriteCond %{REQUEST_FILENAME} .shtml$ [OR]
    RewriteCond %{REQUEST_FILENAME} .php$
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule .*$ /404.htm
    #note that we give it a fake rewrite, to generate a real 404!

    I was tearing my hair out trying to get rid of the parking pages which worked on some bits of my site, but not others, and finally found it was the CheckSpelling Off that made the difference.

  6. Thank you. I was looking around the admin for a while and this saved me a lot of time. Thanks to Anthony’s .htaccess fix. It worked for me.

  7. There I was happy with my custom errorpage.php setup and WHAM! its tops working….. but as 1and1 is known for this (*&()*)&*^&^ I did a search , thank you so much for this.

    Amazing what you dont see when the hosting company ‘hides’ it. in plain sight. I normally use the .htaccess from wordpress but just goes to show what the sharing part of the ‘www’ is so good at. Once again thanks for the pointers – everybody.

  8. error pages should be php e.g. error404.php in order that the server response can be specified within them e.g.

    1and1 servers only allow html error files – this is not liked by google etc.

    Bad practice by 1and1 but I don’t suppose they know or care!

  9. Thnaks for the post. My site is in Spanish hosted by 1 & 1 in Germany – not a good combination for help & Support – so this information was invaluable.

  10. I am very grateful to have found your article – so clearly explaining why I too have been going round and round in circles trying to fix this. For the first time I wanted to allow php within an html file so was bamboozled when testing out my 404 custom error pages!

    Perhaps you could get a job on the 1and1 support team?!

  11. Very good post – thank you so much for taking the trouble, I asked 1&1 support why I got my custom error page (defined via .htaccess) served if the missing page was a .htm, .html etc, but I got the default 1&1 error doc if the missing file was a .php – they couldn’t answer the question?!?
    Your post is the only source I’ve found that does answer the question – and which mentions the errorXXX.html files, I can’t find anything about these in the current 1&1 help/faqs files

  12. Many thanks for posting this solution. 1&1’s posted solution for an htaccess file does not work, as you explained above. Your instructions did the trick. You ought to get some free hosting for this!

  13. 1and1 have started pointing the 404 page to an attack site in russia so I needed this solution – thanks immensely

  14. Hi Frank, 1and1 certainly don’t point people’s 404 pages to attack sites in Russia! What is much more likely is that your site was hacked and someone pointed your 404 page to the attack site. Glad you fixed the problem.

  15. Thanks much for this tip – helps tremendously ! I’ve spent the last 2 days trying to solve this. I had a custom 404 page with an .htaccess directive and it would work for URLs like this:

    But not for:

    Additionally, (since I’m using index.php) I get an error 300 for:

    Your solution for an error page in the root now directs ../nopage.php to the correct 404 error page, but that still doesn’t solve the 300 error.

    Additionally, the FAQ you showed is now invalid. There is no longer any “Empty Parking Pages” option. 1&1 Tech support told me this option had been “demoted” (not sure what that means) and they could offer me no alternative — didn’t even know about the solution you shared here.

    As a matter of fact, 1&1 tried to convince me that sometimes going to their 404 page and sometimes to a 300 error was perfectly natural — a feature – lol. But sad really.

  16. Thanks to Anthony (and my Son for reading his comment) for a solution to my last problem: URLs like “…/index.htm”.

    Adding “CheckSpelling Off” to the .htaccess file made all the “300 Multiple Choices” errors go away. Hallelujah !

  17. @Anthony Wieser: Your method works but must be at the end of the htaccess file, after any other rewrite rules.


  18. I know this is an old thread but the problem is still valid…

    Anyway, they moved the Domain parking link after they redid their site.

    To find it, go to the control panel, click the “Domains” text (not the domain center or anything below it)

    On the bottom on the left-hand side you see the Sedo Domain Parking. I’m not sure how long it takes to go into effect, but at least you know where it is.

Leave a Reply

Your email address will not be published. Required fields are marked *

Do NOT fill this !