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.
- Inside your Joomla web directory, copy the error.php file from templates/system to root of your template directory (not your Joomla directory).
- 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.
- 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.*
Comments 3
It worked. Thanks.
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.
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