Just to add to what Josh L posted above, mod_speling can be good for taking care of some of the typos, though obviously is not ideal for those worried about performance. It does, however, check both spelling and capitalisation.
In addition, if you are do use a server side language to serve up your 404 pages (and other error docs), it can be extremely beneficial to have the page email you whenever an error doc is served. Ideally, include all request headers with it too, so you can track down the cause of the error.
Thanks for everyone who has commented so far. It has caught me off guard a little though, and as editor Erin pointed out, it’s also happening while I’m on travels and so I might not be able to respond in as timely a fashion as I’d like.
Thanks to James Cridland for building on the ideas I had in the article. I knew there would many other great ideas, so thanks for sharing.
As many have pointed it, there is an irony that in a piece about 404 errors, there has been another error in one of the example 404 pages, that being that the 404 page being served up is coming through as an octet stream. In IE it renders fine but on Firebird it prompts to save the custom 404 page as a file. If anyone knows how to remedy this, please add to the discussion.
Thanks also to Klaus for pointing out that Cross-site scripting was a potential problem. I don’t know how much of a problem this is – I do not have the mind of a hacker! – but I am not married to the notion that the script must be client-side. If the server config allows, I would favour server-side scripting which should, as I understand it, stop (or at least reduce) the spectre of cross-site scripting. If’ I’m wrong, please do tell ASAP.
Copy & paste the code below to embed this comment.
brian
Depending on your setup, it is helpful to add some server-side code into the custom 404 page to eMail the administrator information about the offending link. With PHP it is easy to create a mail message containing the URL (if they mis-typed it you can see what it was) the Referrer (so you can see if google has an outdated link or fix a link within yourown site), and other information like date/time, etc.
If you don’t have the ability to put this code in your custom 404 page, that’s OK. You can create a php file with just the mail function. Then in the HTML of the custom 404 page add a something like this in the head tag.
[removed][removed]
This contains the PHP mail function. If done properly, it will be called when ever someone hits the 404 page.
This will eMail you a heads-up that there is an error. If the offending link is from within the site, you can fix it. If the link comes from a search engine, you can temporarily re-create the link and point it somewhere else. You can even add a snippit of code to the top to tell the search engine the content has permenantly moved
Having a well designed custom 404 page is great, but after one person gets there, you should be making every effort that no one else does. Without any information about what caused the 404, someone is doomed to repeat the error.
I have built a custom 404 page with some of the ideas here and toyed with the idea of an automatic email but a glance at my log files put me off the idea – most of the 404 errors come from script kiddies and worms looking for vulnerable web servers. Instead I plan to add an optional ‘Tell the webmaster’ form. Clicking submit without doing anything else will send the URL but they will have the option to add a comment and a return email.
Back to our current 404 page – Its all server-side using vbscript on an MS box. I use a text file that holds possible matches for the error URL. These include names for our larger directories, URLs for pages that have been moved, wrong URLs that published elsewhere.
If someone has a dud URL that points to somewhere in our ‘rules’ directory, they will be offered a link to the ‘Current rules and regulations’ contents page.
If its a known problem, eg a magazine has published a URL with a typo, we can offer the exact page.
The same idea on our search page gives ‘recommended links’ for our most common search terms.
I’ll have to look at the idea of dealing separately with typos and wrong referrals. What happens when people just chop off the end of the URL looking for an index page? We get a few of those.
If you have to deal with a Microsoft IIS server and would like the code, I’m happy to supply it.
http://casa.gov.au
Does anybody have a good way of going to a URL and specifying a false referrer? Not sure how to test drive all the different pieces of this without, for example, convincing a search engine to link to a nonexistent page in my site…
One thing that is not mentioned in this otherwise good article is that you should have your system set up to send mails or other forms of data to your webmaster/system everytime a 404 fault is registered. This ensures a proactive approach if something is wrong and needs to be fixed i.e. someone in the marketing department has done a mailing with a wrong URL.
No-one’s mentioned this site yet, the “404 Research Lab”: http://www.plinko.net/404/ . Tips and links to lots of custom 404 pages. Nice article btw, pity my ISP won’t let me write a suitable .htaccess file (sigh).
Nate, you can just have a link to a non-existant page from another site. Just post it in a forum or something and click on it. That should work for testing purposes.
In response to the article, I think it has some good ideas. I will not use Javascript to implement this, but I undertsnad why the author did so. Thanks for taking the time to write this article, good ideas!
1. The <!—and //—> comment delimeters for Javascript have not really been needed since Netscape 1.0 died – they were there to prevent browsers that were not aware of the [removed] element from displaying the script verbatim.
2. More importantly: The example error document does not validate as XML, which means that if you attempt to serve this as application/xhtml+xml.
While escaping this with a CDATA section could work in some cases:
.. there are also cases where this theoretically could fail (e.g. if you serve this to a client that doesn’t understand what a CDATA section is, it could throw script errors). If you wanted to satisfy both the pseudo-xhtml-crowd, and the old-browser-crowd, you could use something insanely complex like
In the end – you’d really be better off using an external script that modifies the source of the document – which would also do away with the need for a <noscript> block.
Copy & paste the code below to embed this comment.
andrew waer
Hello… I’ve done a tentative converstion of this to php for those of you who may want it.
It’s kind of tough to debug because I can only check it through www.wannabrowser.com so there may be a few slight errors, but I think it’s pretty close to done. If anyone out there wants to do a double-check of my conversion please do!
Keep in mind that this code will still need to be modified a bit to suit your specific needs.
It’s also posssible to tailor the content of a 404 page based on the file or file type requested (James Cridland hinted at this in an earlier post). For example I cooked up a little something becuase I wanted to offer mp3 downloads for a limited time period, then just delete the files and forget about them (yes, yes, I know, moving/changing urls is very bad practice but sometimes you just can’t help it. I can’t anyway).
I did something like this in php:
if(preg_match(’/mp3$/’ $_SERVER[‘REQUEST_URI’]))
{
echo ‘<!—mp3 match found!—>’;
// custom error message
} else {
// standard 404 error message
}
It at least allows you to offer a little explanation. Trivial demo:
I screwed up my 404 page once; hopefully others might benefit from my mistake.
My host offered “missing.html” as the 404 handler, and I had a basic 404 page done some time ago. Later I converted my site to PHP, and added a directive with mod_rewrite to redirect *.html to *.php. I noticed this stopped loading my 404 page, so I thought I’d just rename missing.html to missing.php.
After a very long time I began to notice my custom 404 page was appearing in search engine results. Turns out my PHP redirect was making errors return a 301 (moved permanently) message instead of 404.
If you mistype the WAP url above, the server will send a 404 status followed by a nice little HTML page.
But WAP phones can’t read HTML, so all the user will see, is “INVALIDFILETYPE”.
Conclusion 1: The WAP gateway should intercept the 404 message, and supply its own WML error page.
Conclusion 2: The WAP gateway doesn’t, so if your site has WAP pages, it should send WML error pages to WAP user agents.
In general, we should always try to send a MIME type that the UA says it will accept. But IE doesn’t say that it accepts text/html, so forget it, see http://landsbank.fo/tools/http.headers/http.headers.html.cfm
Bruce – I agree entirely, it seems like a good idea to include an auto email facility (if you can do this) to notify the webmaster, but it can get out of hand too quickly. Many of these ideas were used in the error 404 for Nationwide Building Society http://www.nationwide.co.uk/ (my place of employment when I’m not slacking around the world!) and the key thing was not to overload some poor admin person. Hence, the technique was an opt-in one – if the page they wanted was important, they’d probably report it otherwise it gets ignored. Or at least that’s the theory!
Copy & paste the code below to embed this comment.
.jon
An error is an error. An exception should not be replaced by anything!
If I download a web-document using a spider or robot I WANT the 404 as an error, not as a page. The ‘invention’ you show us here also break link-checkers, since they simply will find: aha, there is a document on this link, so all is fine.
Usability is to be enhanced by applications, not by data-files. If the data is missing it is missing. If the programmer of the web-server wants to analyze the user-agent-string and send a special document: ok. If the browser does offer a better option: ok. But if the server sends a search- and report-form to the robot: bad!
Copy & paste the code below to embed this comment.
andrew waer
Read the provided links. This is not a hack, this is an encouraged standard by Apache.
ErrorDocument is an Apache directive that only customizes a standard Apache response containing important HTTP header information (404/301/etc). The URL http://www.mydomain.com/error/404.html is not going to be written to your browser’s address bar.
Apache will serve the appropriate header information, i.e. the 404, and then provide this page in place of the incorrectly requested one. Google does not catalog pages that give the appropriate 404 header information, nor 301, etc. You can deny direct access to those files by simply adding a ‘Deny From All’ htaccess file in the error directory itself.
The page that is served in conjunction with ErrorDocument is exactly the same as what you WANT and GET, this is only Apache’s way of allowing you to customize it’s look, feel, & functionality.
If all attempts to locate the content fail, Apache returns an error page with HTTP status code 404 (file not found). The appearance of this page is controlled with the ErrorDocument directive and can be customized in a flexible manner as discussed in the Custom error responses and International Server Error Responses documents.
Better late than never.
Ian and Andrew inspired me to write an ASP custom 404 page based on their ideas/design/style. Which is useful because I can actually use it for the health systems’ website that I manage. I believe simple and consistent options for all platforms could make 404 error pages useful across the board.
Copy & paste the code below to embed this comment.
paul roberts
from experience…
if you use apache’s mod spelling then that’s it for server side (untill apache 2).
if your isp has mod spelling turned on, you can turn it off with .htaccess but your error page (php etc) will still not run as the page has already been sent to mod spelling.
MSIE/PC is per default set to
“Show friendly HTTP Error Messages”
thus making it impossible for ca. 95% of all users to benefit from the article’s idea as they are presented with what MSIE thinks is a good 404. (or 401 or the like)
The default setting can be overruled easily but most users don’t (and wouldn’t know about it anyway).
Web developers tend not to use MSIE for private surfing, (quite OK) so I guess that’s how the article came into beeing; good idea, but not fitting reality.
By the way, I don’t see the point for relaying on client side scripting, server side offers the same possibilities here and wouldn’t exclude ca. 10% of all users.
(some stats state that number for JS-less users)
Copy & paste the code below to embed this comment.
Charles
octet-stream solution (re Ian’s page 3 post)
“…there has been another error in one of the example 404 pages, that being that the 404 page being served up is coming through as an octet stream. In IE it renders fine but on Firebird it prompts to save the custom 404 page as a file. If anyone knows how to remedy this, please add to the discussion.”
IE violates the W3C rule of using MIME-type to determine how to handle a file; it uses the dot-extension instead. So IE will work fine with application/octet-stream (a default MIME type for some servers) while standards-compliant browsers will attempt to download the file. The solution is to send .asp files out with the proper MIME type.
In Apache, you would put this line in the .htaccess file of the root folder of your Web site (if you are the server master, you would put it in httpd.conf in /www/conf instead):
AddType text/html .asp
Other Web servers may use other syntax and files.
—————————————————
re: MSIE 404 default
The MSIE default page for 404’s and other server errors only shows if the site-supplied 404 page is shorter than a certain number of bytes, 512 I believe. If you want to show a custom page, you need to make sure it is longer than that length, so don’t be too terse.
>The MSIE default page for 404’s and other
>server errors only shows if the site-
>supplied 404 page is shorter than a certain
>number of bytes, 512 I believe.
I tried this with MSIE6/WinXP, works well, 512b is the exact threshold.
Thanks for the info, calling the article “useless for 95% of all users” was rash, I apologize.
I read your article and then got to work on my site! Inspiration I tell you.
Anyway, while researching the 404 custom error page thingy, I stumbled onto this site, http://www.plinko.net/404/ Someone has dedicated a section of their site to custom 404 pages. That’s amazing!
Some people redirect every 404 Error to their Main 404 page. So I loose the original URL in the case I’d like to debug my incorrectly typed URL or to hack it in order to look what I can find around.
So, whatever 404 page you put, please, don’t redirect the user somewhere else.
What might be a good feature to have on 404 pages is a link to google’s cache, entering the adress that creates the 404 error. It might help the users to get what they are looking afterall.
Good solid article with useful info. Check out Apple’s 404 error page (http://www.apple.com/gobbledeegook) – they seem to have really hit the nail on the head here.
Copy & paste the code below to embed this comment.
amix
There is no reason for 404 error pages.
In the years I am browsing the web, no single 404 page has helped me and your approach does not help either.
The site is either searchable or not. If so, what does it cost to return to the top or the previous page and access a search box there ?
404 is an error. An exception. It means: No document at given location.
This is important ! Robots, Spiders, Downloaders use this to compute results. And these programs are the ‘other’ users of the web. You simply let them not read.
Whenever I mirror a site with ‘wget’ I am very angry for all those 404-error-pages, that mean nothing to me. Even worse, this way sepcialized programs are not able to determine “holes” in a web-document.
How with an error is being dealt is solely up to the clients programmer and user, not (!) to the web-designer.
The web would be much nicer, if more web-designers would realize, that the internet is not a human-only territory.
57 Reader Comments
Back to the ArticleILoveJackDaniels
Just to add to what Josh L posted above, mod_speling can be good for taking care of some of the typos, though obviously is not ideal for those worried about performance. It does, however, check both spelling and capitalisation.
In addition, if you are do use a server side language to serve up your 404 pages (and other error docs), it can be extremely beneficial to have the page email you whenever an error doc is served. Ideally, include all request headers with it too, so you can track down the cause of the error.
Ian Lloyd
Thanks for everyone who has commented so far. It has caught me off guard a little though, and as editor Erin pointed out, it’s also happening while I’m on travels and so I might not be able to respond in as timely a fashion as I’d like.
Thanks to James Cridland for building on the ideas I had in the article. I knew there would many other great ideas, so thanks for sharing.
As many have pointed it, there is an irony that in a piece about 404 errors, there has been another error in one of the example 404 pages, that being that the 404 page being served up is coming through as an octet stream. In IE it renders fine but on Firebird it prompts to save the custom 404 page as a file. If anyone knows how to remedy this, please add to the discussion.
Thanks also to Klaus for pointing out that Cross-site scripting was a potential problem. I don’t know how much of a problem this is – I do not have the mind of a hacker! – but I am not married to the notion that the script must be client-side. If the server config allows, I would favour server-side scripting which should, as I understand it, stop (or at least reduce) the spectre of cross-site scripting. If’ I’m wrong, please do tell ASAP.
brian
Depending on your setup, it is helpful to add some server-side code into the custom 404 page to eMail the administrator information about the offending link. With PHP it is easy to create a mail message containing the URL (if they mis-typed it you can see what it was) the Referrer (so you can see if google has an outdated link or fix a link within yourown site), and other information like date/time, etc.
If you don’t have the ability to put this code in your custom 404 page, that’s OK. You can create a php file with just the mail function. Then in the HTML of the custom 404 page add a something like this in the head tag.
[removed][removed]
This contains the PHP mail function. If done properly, it will be called when ever someone hits the 404 page.
This will eMail you a heads-up that there is an error. If the offending link is from within the site, you can fix it. If the link comes from a search engine, you can temporarily re-create the link and point it somewhere else. You can even add a snippit of code to the top to tell the search engine the content has permenantly moved
header(“Status : 301 Moved Permanently”);
header(“Location: correct_link/”); /* Redirect browser */
exit;
Having a well designed custom 404 page is great, but after one person gets there, you should be making every effort that no one else does. Without any information about what caused the 404, someone is doomed to repeat the error.
Bruce Bowden
I have built a custom 404 page with some of the ideas here and toyed with the idea of an automatic email but a glance at my log files put me off the idea – most of the 404 errors come from script kiddies and worms looking for vulnerable web servers. Instead I plan to add an optional ‘Tell the webmaster’ form. Clicking submit without doing anything else will send the URL but they will have the option to add a comment and a return email.
Back to our current 404 page – Its all server-side using vbscript on an MS box. I use a text file that holds possible matches for the error URL. These include names for our larger directories, URLs for pages that have been moved, wrong URLs that published elsewhere.
If someone has a dud URL that points to somewhere in our ‘rules’ directory, they will be offered a link to the ‘Current rules and regulations’ contents page.
If its a known problem, eg a magazine has published a URL with a typo, we can offer the exact page.
The same idea on our search page gives ‘recommended links’ for our most common search terms.
I’ll have to look at the idea of dealing separately with typos and wrong referrals. What happens when people just chop off the end of the URL looking for an index page? We get a few of those.
If you have to deal with a Microsoft IIS server and would like the code, I’m happy to supply it.
http://casa.gov.au
= crutons.com =
If you are scripting a custom 404 page then it is critical to send appropriate headers. For example:
<?php
header(“HTTP/1.0 404 Not Found”);
?>
This will inform user agents (such as Googlebot) that the page is a 404.
nate cook
Does anybody have a good way of going to a URL and specifying a false referrer? Not sure how to test drive all the different pieces of this without, for example, convincing a search engine to link to a nonexistent page in my site…
Aaron Wall
Thought your article was great. Linked to it in this weeks newsletter I just sent out :)
Jesper Wacherhausen
One thing that is not mentioned in this otherwise good article is that you should have your system set up to send mails or other forms of data to your webmaster/system everytime a 404 fault is registered. This ensures a proactive approach if something is wrong and needs to be fixed i.e. someone in the marketing department has done a mailing with a wrong URL.
Chris Hunt
No-one’s mentioned this site yet, the “404 Research Lab”: http://www.plinko.net/404/ . Tips and links to lots of custom 404 pages. Nice article btw, pity my ISP won’t let me write a suitable .htaccess file (sigh).
Eric
Nate, you can just have a link to a non-existant page from another site. Just post it in a forum or something and click on it. That should work for testing purposes.
In response to the article, I think it has some good ideas. I will not use Javascript to implement this, but I undertsnad why the author did so. Thanks for taking the time to write this article, good ideas!
George Carless
I quite like the 404 page at The Sisters of Mercy’s web site ..(http://www.thesistersofmercy.com/error404page.html)
Arve Bersvendsen
1. The <!—and //—> comment delimeters for Javascript have not really been needed since Netscape 1.0 died – they were there to prevent browsers that were not aware of the [removed] element from displaying the script verbatim.
2. More importantly: The example error document does not validate as XML, which means that if you attempt to serve this as application/xhtml+xml.
While escaping this with a CDATA section could work in some cases:
[removed]
<![CDATA[
… unescaped script content …
]]>
[removed]
.. there are also cases where this theoretically could fail (e.g. if you serve this to a client that doesn’t understand what a CDATA section is, it could throw script errors). If you wanted to satisfy both the pseudo-xhtml-crowd, and the old-browser-crowd, you could use something insanely complex like
[removed]<!—//—><![CDATA[/><!—
…unescaped script content
//—><!]]>[removed]
In the end – you’d really be better off using an external script that modifies the source of the document – which would also do away with the need for a <noscript> block.
andrew waer
Hello… I’ve done a tentative converstion of this to php for those of you who may want it.
It’s kind of tough to debug because I can only check it through www.wannabrowser.com so there may be a few slight errors, but I think it’s pretty close to done. If anyone out there wants to do a double-check of my conversion please do!
Keep in mind that this code will still need to be modified a bit to suit your specific needs.
http://www.sitepoint.com/forums/showthread.php?p=1076762
Kev
It’s also posssible to tailor the content of a 404 page based on the file or file type requested (James Cridland hinted at this in an earlier post). For example I cooked up a little something becuase I wanted to offer mp3 downloads for a limited time period, then just delete the files and forget about them (yes, yes, I know, moving/changing urls is very bad practice but sometimes you just can’t help it. I can’t anyway).
I did something like this in php:
if(preg_match(’/mp3$/’ $_SERVER[‘REQUEST_URI’]))
{
echo ‘<!—mp3 match found!—>’;
// custom error message
} else {
// standard 404 error message
}
It at least allows you to offer a little explanation. Trivial demo:
http://malaise.sorehead.org/nosuchpage.html
http://malaise.sorehead.org/nosuchsong.mp3
There’s probably a dozen better ways to do the same thing, but that seemed to work for me.
Kev
Or, if you prefer your php to parse correctly subsitute:
if(preg_match(’/mp3$/’, $_SERVER[‘REQUEST_URI’]))
andrew waer
looksmart has changed their search param from ‘key’ to ‘qt’
Stewart Vardaman
I screwed up my 404 page once; hopefully others might benefit from my mistake.
My host offered “missing.html” as the 404 handler, and I had a basic 404 page done some time ago. Later I converted my site to PHP, and added a directive with mod_rewrite to redirect *.html to *.php. I noticed this stopped loading my 404 page, so I thought I’d just rename missing.html to missing.php.
After a very long time I began to notice my custom 404 page was appearing in search engine results. Turns out my PHP redirect was making errors return a 301 (moved permanently) message instead of 404.
Jan Egil Kristiansen
If you mistype the WAP url above, the server will send a 404 status followed by a nice little HTML page.
But WAP phones can’t read HTML, so all the user will see, is “INVALID FILE TYPE”.
Conclusion 1: The WAP gateway should intercept the 404 message, and supply its own WML error page.
Conclusion 2: The WAP gateway doesn’t, so if your site has WAP pages, it should send WML error pages to WAP user agents.
In general, we should always try to send a MIME type that the UA says it will accept. But IE doesn’t say that it accepts text/html, so forget it, see http://landsbank.fo/tools/http.headers/http.headers.html.cfm
Ian Lloyd
Bruce – I agree entirely, it seems like a good idea to include an auto email facility (if you can do this) to notify the webmaster, but it can get out of hand too quickly. Many of these ideas were used in the error 404 for Nationwide Building Society http://www.nationwide.co.uk/ (my place of employment when I’m not slacking around the world!) and the key thing was not to overload some poor admin person. Hence, the technique was an opt-in one – if the page they wanted was important, they’d probably report it otherwise it gets ignored. Or at least that’s the theory!
Vanhalle Jean-Christophe
Hello. I read and i didn’t see anyone posting the url to this site : http://www.404lounge.net/
This is a nice gallery.
.jon
An error is an error. An exception should not be replaced by anything!
If I download a web-document using a spider or robot I WANT the 404 as an error, not as a page. The ‘invention’ you show us here also break link-checkers, since they simply will find: aha, there is a document on this link, so all is fine.
Usability is to be enhanced by applications, not by data-files. If the data is missing it is missing. If the programmer of the web-server wants to analyze the user-agent-string and send a special document: ok. If the browser does offer a better option: ok. But if the server sends a search- and report-form to the robot: bad!
andrew waer
Read the provided links. This is not a hack, this is an encouraged standard by Apache.
ErrorDocument is an Apache directive that only customizes a standard Apache response containing important HTTP header information (404/301/etc). The URL http://www.mydomain.com/error/404.html is not going to be written to your browser’s address bar.
Apache will serve the appropriate header information, i.e. the 404, and then provide this page in place of the incorrectly requested one. Google does not catalog pages that give the appropriate 404 header information, nor 301, etc. You can deny direct access to those files by simply adding a ‘Deny From All’ htaccess file in the error directory itself.
The page that is served in conjunction with ErrorDocument is exactly the same as what you WANT and GET, this is only Apache’s way of allowing you to customize it’s look, feel, & functionality.
If you’re still not convinced, read this:
http://httpd.apache.org/docs/mod/core.html#errordocument
http://httpd.apache.org/docs/custom-error.html
http://httpd.apache.org/docs/misc/custom_errordocs.html
Excerpt ::
If all attempts to locate the content fail, Apache returns an error page with HTTP status code 404 (file not found). The appearance of this page is controlled with the ErrorDocument directive and can be customized in a flexible manner as discussed in the Custom error responses and International Server Error Responses documents.
Ed Knittel
Better late than never.
Ian and Andrew inspired me to write an ASP custom 404 page based on their ideas/design/style. Which is useful because I can actually use it for the health systems’ website that I manage. I believe simple and consistent options for all platforms could make 404 error pages useful across the board.
eh – eNjoy…
http://www.tastypopsicle.com/404.asp
Charles Belov
Okay, I added a search for an archival copy of pages that have been deleted from http://www.sfmuni.com
Of course, there is no guarantee that Archive.org will have archived the particular page if it indeed ever existed.
Example of a page we recently deleted.
http://www.sfmuni.com/rid/cac/ca000706.htm
paul roberts
from experience…
if you use apache’s mod spelling then that’s it for server side (untill apache 2).
if your isp has mod spelling turned on, you can turn it off with .htaccess but your error page (php etc) will still not run as the page has already been sent to mod spelling.
Marek Moehling
MSIE/PC is per default set to
“Show friendly HTTP Error Messages”
thus making it impossible for ca. 95% of all users to benefit from the article’s idea as they are presented with what MSIE thinks is a good 404. (or 401 or the like)
The default setting can be overruled easily but most users don’t (and wouldn’t know about it anyway).
Web developers tend not to use MSIE for private surfing, (quite OK) so I guess that’s how the article came into beeing; good idea, but not fitting reality.
By the way, I don’t see the point for relaying on client side scripting, server side offers the same possibilities here and wouldn’t exclude ca. 10% of all users.
(some stats state that number for JS-less users)
Charles
octet-stream solution (re Ian’s page 3 post)
“…there has been another error in one of the example 404 pages, that being that the 404 page being served up is coming through as an octet stream. In IE it renders fine but on Firebird it prompts to save the custom 404 page as a file. If anyone knows how to remedy this, please add to the discussion.”
IE violates the W3C rule of using MIME-type to determine how to handle a file; it uses the dot-extension instead. So IE will work fine with application/octet-stream (a default MIME type for some servers) while standards-compliant browsers will attempt to download the file. The solution is to send .asp files out with the proper MIME type.
In Apache, you would put this line in the .htaccess file of the root folder of your Web site (if you are the server master, you would put it in httpd.conf in /www/conf instead):
AddType text/html .asp
Other Web servers may use other syntax and files.
—————————————————
re: MSIE 404 default
The MSIE default page for 404’s and other server errors only shows if the site-supplied 404 page is shorter than a certain number of bytes, 512 I believe. If you want to show a custom page, you need to make sure it is longer than that length, so don’t be too terse.
Charles
http://www.juicystudio.com/tutorial/xhtml/mime.asp#asp
Please ignore the octet-stream portion of the previous post. Of course, addType wouldn’t work for server-side generated pages.
Marek Moehling
>The MSIE default page for 404’s and other
>server errors only shows if the site-
>supplied 404 page is shorter than a certain
>number of bytes, 512 I believe.
I tried this with MSIE6/WinXP, works well, 512b is the exact threshold.
Thanks for the info, calling the article “useless for 95% of all users” was rash, I apologize.
George Calderon
I read your article and then got to work on my site! Inspiration I tell you.
Anyway, while researching the 404 custom error page thingy, I stumbled onto this site, http://www.plinko.net/404/ Someone has dedicated a section of their site to custom 404 pages. That’s amazing!
Gari Araolaza
One thing that annoys me almost everyday:
Some people redirect every 404 Error to their Main 404 page. So I loose the original URL in the case I’d like to debug my incorrectly typed URL or to hack it in order to look what I can find around.
So, whatever 404 page you put, please, don’t redirect the user somewhere else.
2
What might be a good feature to have on 404 pages is a link to google’s cache, entering the adress that creates the 404 error. It might help the users to get what they are looking afterall.
http://www.google.com/search?q=cache:[pagethatisnotfound]
Trenton
Good solid article with useful info. Check out Apple’s 404 error page (http://www.apple.com/gobbledeegook) – they seem to have really hit the nail on the head here.
amix
There is no reason for 404 error pages.
In the years I am browsing the web, no single 404 page has helped me and your approach does not help either.
The site is either searchable or not. If so, what does it cost to return to the top or the previous page and access a search box there ?
404 is an error. An exception. It means: No document at given location.
This is important ! Robots, Spiders, Downloaders use this to compute results. And these programs are the ‘other’ users of the web. You simply let them not read.
Whenever I mirror a site with ‘wget’ I am very angry for all those 404-error-pages, that mean nothing to me. Even worse, this way sepcialized programs are not able to determine “holes” in a web-document.
How with an error is being dealt is solely up to the clients programmer and user, not (!) to the web-designer.
The web would be much nicer, if more web-designers would realize, that the internet is not a human-only territory.
TEST
TEST
TEST2
TEST2
Dominik
Thank you very much for this great tutorial. It helped me very much.
Good work.
Greetig form Germany
Dominik