This is a newbie question:
I've read a lot about adding 301 redirect code to the .htaccess file in order to fix the problem of search engines mistaking www and non-www domains as duplicate content.
For example - according to Google analytics - Google currently thinks I have 3 domains all with duplicate content:
mydomain.com
MyDomain.com (Each word capitalized)
www.mydomain.com
My question is, does it matter where in the .htaccess file you place the redirect code? Is there a proper order that the various directives need to be in?
The code I'm going to use is:
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^mydomain.com$ [NC,OR]
RewriteCond %{HTTP_HOST} ^MyDomain.com$ [NC]
RewriteRule ^(.*)$ http://www.mydomain.com/$1 [R=301,L]
Do I have the code correct and should I place it somewhere at the top of the file, at the bottom, or somewhere in between?
Everything I've read - from the apache docs to various forums - all just say to add the lines of code. No one ever says where to place it.
Any help would be appreciated,
Dean