|
BLOG: Joomla 1.5 custom 404 error pages
Removing "dead" links from your website, i.e your redirect your 404 pages, helps search engines and also your visitors. If your website visitor visits an old or dead link, they will recieve a standard 404 page not found, and usually leave.
This tip below allows you to create a custom Joomla 1.5 - 404 page to show your visitors a custom Message and also redirect them to your frontpage. Your visitors are then re-directed to that page and it is easy to manage your 404 page through Joomla. When you remove content from your website you dont have to worry about dead links anymore!
Login to Joomla
Create a new article page that you want to display for your users when they bump into 404 error. i.e 404
Add your html which you would like your visitors to see, add a html refesh tag to redirect them to your homepage after 10 seconds.
Now, in your Websites theme “template” directory create a file called “error.php” and add the following code.
<?php
defined( '_JEXEC' ) or die( 'Restricted index access' );
if (($this->error->code) == '404') {
header('Location: ' . $this->baseurl . 'http://www.yourdomain.com.au/404.html');
exit;
}
Example link: “http://www.yourdomain.com.au/404.html” is the url of your 404 article page.
Ensure the 404 page is published and works when you direct navigate to it.
Now is testing time: Navigate to your website, type www.yourdomain.com.au/testbadlink.html
You will now see your new Custom Joomla 404 Error Page.
HTTP status code When a request is made for a page on your site, the server returns an HTTP status code in response to the request. Joomla! returns a '200 - the server successfully returned the page' for error pages. This is problematic for those working with Google Webmaster Services and trying to get a sitemap resolved. If you want Joomla! to return a status code for the error, you can do so by adding logic before the DOCTYPE line, as follows:
<?php if ($this->error->code = '404') { header("HTTP/1.0 404 Not Found"); } ?>
Our Knowledgebase has tons of helpful Information.
|