Prevent friendly error page

You don’t like the friendly error page of MSIE or Chrome?

It is believed to be the length of the 404 html code which decided whether Google auto-changes the error page ("I believe if Google Chrome sees a very short, stock 404 page (less than 512 bytes), it talks to Google in order to try to suggest other possible pages and options" – Source).

Before

Google’s modified 404 style

After

The plain 404 style (or any own layout for that matter)

A simple trick

This trick is from nginx – quite handy, isn’t it?

<html>
<head><title>404 Not Found</title></head>
<body bgcolor="white">
<center><h1>404 Not Found</h1></center>
<hr><center>ServerName</center>
</body>
</html>
<!-- a padding to disable MSIE and Chrome friendly error page -->
<!-- a padding to disable MSIE and Chrome friendly error page -->
<!-- a padding to disable MSIE and Chrome friendly error page -->
<!-- a padding to disable MSIE and Chrome friendly error page -->
<!-- a padding to disable MSIE and Chrome friendly error page -->
<!-- a padding to disable MSIE and Chrome friendly error page -->

You only need to add those comments to your error layouts. Now the browsers can’t transform them into their own style anymore.
As a result the 404 is displayed as it is supposed to 🙂

A few last words

Some go even that far and call it "hijacking". But nonetheless it might be helpful for some unskilled web users to have this hijacking google keyword search in 404s 🙂
But with the above approach a web developer can decide for himself.

4.67 avg. rating (91% score) - 3 votes

1 Comment

  1. not much of a how to " add those comments to your error layouts." wat error layouts where? want to edit the 404 to display my custom message and this just confuses me

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.