How To: Redirect Joomla 3.X 404 Page to Homepage

How To: Redirect Joomla 3.X 404 Page to Homepage

The quick and easy way to redirect any 404 page to your main homepage in Joomla.

 

  1. Inside your Joomla web directory, copy the error.php file from templates/system to root of your template directory (not your Joomla directory).
 
  1. Add the following detection code right below the statement defined( '_JEXEC' ) or die( 'Restricted access' );
 
if (($this->error->getCode()) == '404') {
header('Location: /index.php');
exit;
}

 

If you are using SEO URL’s, you can simply remove index.php leaving only the / in place.





 

  1. Try to browse your website with a link you know does not exist. It should instantly redirect your homepage now!
 

This is best practice for a website that does not have much content (static) or will never receive much content in the future.

 


* Please use the comment form below. Comments are moderated.*



Related Posts

 

Comments 3

Guest - Umit on Tuesday, 15 January 2019 08:37

It worked. Thanks.

It worked. Thanks.
Guest - David on Thursday, 25 February 2016 05:01

I don’t know much about 404 error pages because I had started my blogging career recently.

But somewhere I read that If any blogger or writer deleted the existing web page then the URL of that web page becomes 404 URL and that page becomes 404 page.

It is also said that Google don’t like 404 page so I checked my site whether I had any 404 page or not then I found few of the 404 error pages on my site also.

But Now after reading this post, I can easily handle these pages.

Thanks for sharing such a helpful post with us.

I don’t know much about 404 error pages because I had started my blogging career recently. But somewhere I read that If any blogger or writer deleted the existing web page then the URL of that web page becomes 404 URL and that page becomes 404 page. It is also said that Google don’t like 404 page so I checked my site whether I had any 404 page or not then I found few of the 404 error pages on my site also. But Now after reading this post, I can easily handle these pages. Thanks for sharing such a helpful post with us. :D
on Thursday, 25 February 2016 06:54

AS long as you redirect them to a working page on your site you should be just fine Your CMS backend should have built in plugins to also help mange where people are landing on your 404's

AS long as you redirect them to a working page on your site you should be just fine :) Your CMS backend should have built in plugins to also help mange where people are landing on your 404's
Sunday, 17 November 2024