My family has been buying Mac's since I no longer do their Windows tech support. Now I'm Apple Tech support. Can't win.

SEO and .htaccess

I’m doing some SEO updates for a client, and have come across a tidbit of information concerning the way Google splits rankings among domains. My clients site currently has rankings under domain.com, domain.net, and www.domain.com. Our SEO guy recommends that only www.domain.com be promoted, so that search rankings are not split between domains.

How did I go about this?

I started by looking at the .htaccess file for domain.com. I noticed that there were not any 301 redirects.

Entering the URL without a ‘www’ should use a HTTP 301 redirect to www.domain.com. Again, you want to work towards having one definitive URL for the site homepage to avoid rankings being split.

Most commands in .htaccess are meant to be placed on one line only, so if you use a text editor that uses word-wrap, make sure it is disabled.

This is how it looks in your .htaccess file:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^yourdomain\.com$
RewriteRule ^.*$ http://www.yourdomain.com%{REQUEST_URI} [R=permanent,L]

Now if you have other domains pointing to your main domain, you can use this:

RewriteCond %{HTTP_HOST} !domain.com$
RewriteRule ^(.*)$ http://www.domain.com/$1 [L,R=301]

this makes any other domain, such as domain.net, into www.domain.com.

As you can see, alot can be done with the .htaccess file. For more info on this just Google 301 redirects or .htaccess.

Here is a great tutorial regarding the use of .htaccess.

One Response to “SEO and .htaccess”

  1. Thanks, that came in handy! I can never remember all those .htaccess rule off the top of my head.