Redirect yourdomain.com to www.yourdomain.com
If both yourdomain.com and www.yourdomain.com are working and you want yourdomain.com to be redirect to www.yourdomain.com, you must add the following two lines to your .htaccess file in the website’s root folder:
rewritecond %{http_host} !^www.yourdomain.com [nc]
rewriterule ^(.*)$ http://www.yourdomain.com/$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’ ) ;
exit();
}
?>
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