I have an add-on domain pointing to the main site. I can't do a 301 redirect because many companies block the main domain. Now, google is indexing both domains causing duplicate content. Can anyone help me fix this?
Just use the robots.txt file to block one of the sites entirely... simple fast solution for what you are looking for in your case. Just add the below code in a file called robots.txt in your root directory. User-agent: * Disallow: / Code (markup):
Because both domains point to the exact same content (intended result), I don't think a robots.txt to block just 1 without blocking the other. How do I use htaccess to redirect it, without making the domain name change to the blocked name?
Then make a dynamic robots.txt. Open a PHP editor and create a php file that contains: <? if ($_SERVER['HTTP_HOST'] == 'www.thedomaintobedisallowed.com') {echo "User-agent: * \n Disallow: /";} else echo 'the content of the other robots.txt file'; ?> Code (markup): and upload the file in ROOT directory (where index file is). Then in your .htaccess file after Options +FollowSymlinks RewriteEngine On add this line RewriteRule ^robots.txt robots.php Code (markup): Hope that helps.
I have 3 going to my site and never had a problem. Can't you still set a preferred domain in webmaster tools? That's what I did a while ago