<?
Header( "HTTP/1.1 301 Moved Permanently" );
Header( "Location: http://www.new-url.com" );
?>
Options +FollowSymLinks
RewriteEngine on
RewriteRule (.*) http://www.yourdomain.com/$1 [R=301,L]
Dean26 said:Thanks, rep added. Could you show me what to put in the .htaccess to achieve this?
Dean26 said:I tried adding the code to .htaccess but firefox gives me a redirect loop error. Any ideas?
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www.your_domain.com [NC]
RewriteRule ^(.*)$ http://your_domain.com/$1 [L,R=301]
peter@flexiwebhost said:The following htaccess should work.
Code:RewriteEngine on RewriteCond %{HTTP_HOST} ^www.your_domain.com [NC] RewriteRule ^(.*)$ http://your_domain.com/$1 [L,R=301]
i strongly advise against using php to do this as it creating a lot more work for your server.
Regarding this optimizing both www. and non www. It does nothing of the sort. It simply optimizes the 1 that is being redirected too so that all incoming links etc count towards that 1 path.
If you tried optimizing both and getting them both in the SERPS you run the risk of duplicate content as well as needing to do a lot more work to get either of them anywhere near the top.
Thanks, but I am not sure if it is working. They both show the website but they already did that before and the URL in the address bar doesnt change either way so I am not sure if it is redirecting.peter@flexiwebhost said:The following htaccess should work.
Code:RewriteEngine on RewriteCond %{HTTP_HOST} ^www.your_domain.com [NC] RewriteRule ^(.*)$ http://your_domain.com/$1 [L,R=301]
i strongly advise against using php to do this as it creating a lot more work for your server.
Regarding this optimizing both www. and non www. It does nothing of the sort. It simply optimizes the 1 that is being redirected too so that all incoming links etc count towards that 1 path.
If you tried optimizing both and getting them both in the SERPS you run the risk of duplicate content as well as needing to do a lot more work to get either of them anywhere near the top.
AuthName mysite.com
Dean26 said:Thanks, but I am not sure if it is working. They both show the website but they already did that before and the URL in the address bar doesnt change either way so I am not sure if it is redirecting.
Also does it matter which one is optimised or does it not make a difference?
Dean26 said:weblord I edited my post and u posted at the same time so check what I wrote at the end![]()
Dean26 said:Doesnt matter, I got peter's code working now. They both redirect to domain.com so is it better like that or is it better to have them both redirect to www.domain.com or no difference either way?



