If, like me, you’ve been promoting your website with both the www tag included and without the www tag, you’ll have been dividing your efforts as far as the search engines are concerned, because technically they are regarded as different websites. Using your .htaccess file on a server running Apache, you can recombine your Page Rank quite easily!
In my .htaccess file for the root of my domain (i.e. where I put myfile.html if I want to access it as [...].net/myfile.html), I added the following code to cause accesses to www.(domainname) to be redirected to (domainname), and the code required was surprisingly short:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^w+\.theaffiliatemarketer\.net$
RewriteRule ^(.*)$ http://theaffiliatemarketer.net/$1 [R=301]
Note the following:
- The code makes up three lines. The first line starts with RewriteEngine, the second line starts with RewriteCond, and the third line starts with RewriteRule. This is how it must be written in your file. It is shown here word-wrapped.
- You need a backslash before each dot in the RewriteCond line only. This is because this line contains a regular expression, and a dot on its own means “match any character,” whereas a dot preceded by a backslash means “match a dot.” (If you don’t understand that, don’t worry; you don’t have to. You can just run with it.) You must not add backslashes before the dots in the RewriteRule.
- Using w+ rather than www means that this expression will work for www.mydomain.com, ww.mydomain.com, wwww.mydomain.com, wwwwww.mydomain.com
– basically any number of w’s. You might need to add subdomains for ww and wwww etc, and if this is the case then you would need to use the same rewrite rule in the root folders of these subdomains wherever the root folder differs. - If you already have a .htaccess file in this directory, adding these lines before any other rewrite rules should be OK. I’m not sure if it would work well if you have it after any other rewrite rules. RewriteEngine On only has to be there once. It doesn’t hurt to have it in the file more than once.
- Some web hosting providers don’t let you use .htaccess. It will only work for those that run Apache and let you use .htaccess. This usually includes Unix-based servers, but not Windows-based servers.
What it does is to tell anybody accessing the www URL of your site that it’s been permanently redirected to the equivalent non-www URL, and that includes the search engines, so if, like me, you’ve been promoting your web site with both URL variants, this will tell the search engines that the two web sites are one and the same, and will cause the Page Rank for links to both to be combined. I have read elsewhere that somebody else applied this tactic, and they started to get more traffic from doing it.
David Thomas, The Affiliate Marketer