|Joomla Custom 404 page and Server Status Codes|
Since I am migrating my sites from frontpage to joomla, the search engines are still showing my old links. The joomla 404 page is pretty blah.
I found a tutorial at [docs.joomla.org...] which shows how to create a joomla custom 404
|Four Steps to Creating a Custom 404 Error Page |
1. Create an Uncategorized '404' Article
Create an 'uncategorized' article in Joomla! to serve as your 404 Page. Include some text such as Sorry, we could not find the page you were looking for... and if necessary, also any useful navigational links. For example, you may wish to add a link back to your site's home page.
2. Create and copy a link to that new 404 Article.
Create a menu item which links to the new 404 Article and 'apply' your changes. Then copy the URL information (index.php?optio...), set the menu item as 'unpublished' and close out of the menu editing page. You may want to paste the copied URL into Notepad or somewhere accessible for the time-being.
3. Copy error.php to your Template's Directory
In your Joomla! installation copy the file error.php from the templates/system directory, to your Template directory. For example, if I was using a template named 'Cleancloud' I would copy the error.php file to the templates/cleancloud directory.
4. Modify error.php to Redirect 404 Errors to your 404 Article
Edit the error.php file as follows, adding the code below immediately under the 'restricted access' line:
I followed that and it shows a pretty nice 404 page that is a joomla article. HOWEVER, I tested it with an online server status code checker. It was showing as
HTTP Status Code: HTTP/1.1 302 Found
Is the 302 status code OK? I tried to change the php header command to give a 404 and that doesn't seem to work. It throws me back to the windows IE 404 page.
NOTE - the directions say to copy the error.php from the system template to the template you are using. I modified the error.php in the system template folder and that seemed to work OK. That way, if I put a new template up, then the error messages should still work.
Anyway, if the 302 is an acceptable return, then I'm done with this project and I can get on the mower and tackle part of the lawn.
A 302-Found response for invalid URLs is unacceptable.
For "missing pages" there are three valid responses: A 410-Gone for intentionally removed resources, a 301-Moved Permanently redirect to a specific replacement page or corrected URL if one exists, or a 404-Not Found if neither of the previous conditions apply.
Returning the correct server status is more important than anything else, especially whether the error page is pretty or not. Search engines don't even look at the error page, they only look at the server status response code.
Returning a 302 status means that any URL requested from your server for which content cannot be provided will result in a 302-Found redirect, followed by a 200-OK if the redirected=to URL is subsequently requested. So the search engine view of this is that an infinite number of URLs exist on your site, and they will arbitrarily limit the depth to which they are willing to crawl your site.
If you watch your logs carefully, you will see occasional requests for "nonsense" URLs coming from Googlebot, Slurp, etc. -- These are not mistakes, nor are they accidental. They are testing your server to see if it returns proper error codes.
You might want to dig around in Joomla-specific forums to see if there is a better solution, or if someone makes a "plug-in" to fix this issue. If there is no solution, please post back here, because I'm sure that many webmasters considering Joomla would abandon the idea if they can't even get 404-Not Found responses right...
[added] To avoid MSIE's "we're smarter than Webmasters" error pages and to ease your testing, consider using Firefox and the "Live HTTP Headers" add-on for Firefox and other Mozilla-based browsers. Alternately, go into MSIE's advanced options and turn off "Show friendly HTTP error pages." [/added]
Thanks for the input. I've settled on a little workaround for now.
1. I'll leave the regular joomla error message in place. That returns a 404 for non existant URLs.
2. I opened up the template/system/css/error.css and changed the font size to 14. That makes the error message a bit more readable.
That will solve my immediate problem. I'll keep an eye open for any solutions that will allow me to create a custom 404 that is integrated with joomla. I did see one version where you can include the headers and footers but it probably isn't worth the effort right now.
By simply increasing the font size, the standard joomla error page is a lot more readable. When I get a chance, I can play with the php in the error.php and customize the page a bit more.
This was common in lots of CMS 3-4 years ago. I thought everyone had fixed it. Are you seeing this with the latest Joomla version?
Ironically, I did a t search for "Joomla Valid 404" and got a link to the extension directory and it returned... a 404. A valid one too. Here's my abbreviated HTTPLiveHeaders output:
GET /extensions/490/details HTTP/1.1
HTTP/1.1 404 Not Found
Date: Wed, 05 May 2010 15:43:24 GMT
So I wonder if there's something wrong with your install.
Also, I believe most Joomla users are running shSEF404 (Is that the one?) in addition to core SEF
I don't know if it helps with 404s.