Redirects in .htaccess on a Joomla based website

Redirect to

If both and are working and you want to be redirect to, you must add the following two lines to your .htaccess file in the website’s root folder:

rewritecond %{http_host} !^ [nc]
rewriterule ^(.*)$$1 [L,R=301]

Redirect errordocument 404

On a Joomla site you can normally not redirect the 404 error to a new page using the .htaccess file. Instead you must add a code snippet to the following file /templates/system/error.php (added code in bold):

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

if ($this->error->code == 404){
header( ‘Location: enteryoururlhere’ ) ;


On a non joomla site it should be enough to add the following line to the .htaccess file to get the redirect sorted:

ErrorDocument 404 enteryoururlhere

Comments are closed.