I found that it is usually a good idea, to redirect all trafic that doesn’t have www infront of the domain to www.domain.com. I explain how to do it with apache mod_rewrite in the end of the post, scroll there if you just need the answer.

Let’s say, a user types http://domain.com he should redirect to http://www.domain.com
Or one visits http://domain.com/example.html he should forwarded to http://www.domain.com/example.html

You should do that, or the oposite, (any user goes to http://www.domain.com/example.html must be forwarded to http://domain.com/example.html )

You should really follow one way or another. I don’t have any reason to choose one or the other, i you think of any one please write it in a comment. What i could think was, if it’s a long domain, loose the www, if it is a small one, add it.

Some of the reasons to do this trick:

  1. SEO (Search Engine Optimization reasons). Google will find dublicate content and will index two same pages every time. This is never good for you. Google will think you are copying another website (which is yourself). With php scripts and all that, the page on http://www.domain.com/example.php and http://domain.com/example.php will appear as 2 different pages with slightly different contents.
  2. Another SEO reason: Google will index less of your sites. This is because each page counts for 2 pages if you don’t and Google somehow has a limit for each website, how many pages will index, and you will reach that number more easily. It is better to each time to index a unique time.
  3. It’s more beautiful and organized, all your pages look the same.

That’s it, i have no more reasons. Maybe you can suggest one in the comments 🙂

So how to do it:

1) In apache web server:

  1. Download .htaccess file from your web server. It is in the www or public_html folder of your server.
  2. Add the following into it: [code]RewriteEngine onRewriteCond %{HTTP_HOST} ^r00t.gr
    RewriteRule (.*) http://www.r00t.gr/$1 [R=301,L][/code] Replace r00t.gr with your domain
  3. Upload the file again.


If you have wordpress, this won’t work. All you have to do in wordpress is:

  1. Login in wordpress as admin
  2. Click Settings
  3. Change the Site address (URL) and WordPress address (URL) to what you want (with or without www)

WordPress manages .htaccess on it’s own, which is a pain in the ass sometimes and gets a lot of errors, but the good thing is you don’t have the problems explained before.

So that’s it. If i said something wrong or you have something to add to the article, please write a comment and i will see and take that into account.