Monday, July 23, 2012

Custom 404 page in Joomla

In SEO perspective, the website should have a 404 error page with proper links to the site. According to Google SEO guide, avoid using a design for your 404 pages that isn’t consistent with the rest of your site.

To change the default 404 error page in Joomla 1.5 is quite easy. Just follow these easy steps:


Create a normal article with some message to the users who have arrived on the error page. Publish this article as a menu item and grab the URL for the article. 

It will be like: 

http://www.joomla.in/index.php?option=com_content&view=article&id=122

Now you need to edit the file which contains the code for 404 error page in Joomla. Open the file templates/system/error.php in any editor. 

Just below this line:

 defined( ‘_JEXEC’ ) or die( ‘Restricted access’ ); 

add the following code:
if (($this->error->code) == ’404′) {
header(‘Location: ‘ . $this->baseurl .’index.php?option=com_content&view=article&id=122′);
exit;
}
?>


Replace the old error.php file with this one.

Now you can open any non-existent URL on your website like http://www.domainname.com/non-existent-url.html and you will find that the custom error page has opened.

SEO Master: Sukanto Saha

Odesk Hire Link: 
 

No comments: