Often while doing website reviews we find that the www and non www urls of a domain don’t actually point to the same place. A lot of people don’t realise that www.yourdomain.com is actually a subdomain of yourdomain.com. This can lead to poor performance of your site in SEO terms. Having two paths to the same page can dilute the effective authority of your pages in the search engines index.
There is really only one solution to this problem and its called a 301 redirect. A permanent redirection from one URL to another performed by your web server.
Warning this is a techie.
It requires you to modify a server side file, either the .htaccess file on an apache server or a httpd.ini file on a windows server add this code to the top of either file. It will redirect the www URL to the non-www domain name. We prefer to do it this way because the www domain is actually a subdomain however some people prefer to redirect the non-www URL to the www domain.
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.yourdomain.com [NC]
RewriteRule ^(.*)$ http://yourdomain.com/$1 [R=301,L]
Note: remember to change yourdomain.com to your registered domain name.
Below is a concise solution to both where you don’t have to edit in your domain name. Select one and add the code to your server side files.
Redirect to the www
RewriteEngine On
RewriteCond %{HTTP_HOST} !^(www\.|$) [NC]
RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
Redirect to the non-www
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.|$) [NC]
RewriteRule ^ http://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
I can’t seem to get your windows httpd.ini to work on a particular site. I’m used to doing this on an Apache server, but the Windows one seems a bit trickier. Any ideas? Thanks!