My problem seems simple to me but I cannot find a simple solution. Here goes: I have one main domain, and multiple domains pointing to that main domain. To avoid duplicate content I'm trying to redirect all "secondary" or "parked" domains to my main domain so that it resolves to this:
- www.parkeddomain1.com => www.maindomain.com
- www.parkeddomain2.com => www.maindomain.com
- www.parkeddomain3.com => www.maindomain.com
And so on...
Now I have found this htaccess code that is sort of a catch-all solution (which I would prefer):
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www.maindomain.com$
RewriteRule ^(.*)$ http://www.maindomain.com/$1 [R=301]
So this code works when I'm dealing only with straightforward parked domains, not with parked domains with subfolders or subfiles. So:
- www.parkeddomain1.com => www.maindomain.com
redirect works fine here but when I add a subfolder this happens:
- www.parkeddomain1.com/subfolder/ => www.parkeddomain1.com/subfolder/
when what I'm looking for is:
- www.parkeddomain1.com/subfolder/ => www.maindomain.com/subfolder/
All this in order to avoid the duplicate content problem with search engines.
Thanks to all for any answer that would guide me to a solution.
Cheers!