RSS
 
15. Jan. 2011

Prevent friendly error page

15 Jan

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 (92% score) - 3 votes
 
1 Comment

Posted by Mark in WebDevelopment

 

Tags: ,

Leave a Reply

Tip:
If you need to post a piece of code use {code type=php}...{/code}.
Allowed types are "php", "mysql", "html", "js", "css".

Please do not escape your post (leave all ", <, > and & as they are!). If you have encoded characters and need to reverse ("decode") it, you can do that here!
 

 
  1. mark

    October 20, 2013 at 20:09

    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