Hi, On one of my hosting accounts I have a main domain, then several addon domains. Some of the URL's inside of the sites on the addon domains were accidentally pointing to a page using the subdomain (for example, they were using addonsite.mainsite.com/directory instead of http://www.addonsite.com/directory), so now in Google, a :site search for my main domain shows several addonsite.mainsite.com/directory listings, and I would like them to drop those pages out of the index. I can't use noindex nofollow because I still want those pages to be indexed using the addon domain's URL. Is there a way to get rid of those listings using robots.txt? If so, what would I put in the robots.txt file? Thanks, Matt
If you use PHP you should consider the following approach for the those pages in the <head> section: if( $_SERVER["HTTP_HOST"] === "addonsite.mainsite.com" ) { echo "<meta name='robots' content='noindex, nofollow'>"; } PHP:
I would recommend to set up the 301 permanent redirect with .htaccess like this: RewriteCond %{HTTP_HOST} addonsite\.mainsite\.com RewriteRule (.*) http://www.addonsite.com/$1 [R=301,L] Code (markup): This might help to save Google PR if you have inbound links to addonsite.mainsite.com/directory.
Thanks, but I'm not able to get it working. Here is what I have: RewriteCond %{HTTP_HOST} addonsite\.mainsite\.com/directory RewriteRule (.*) http://www.addonsite.com/directory/$1 [R=301,L] but it is not redirecting. I also tried it without the /directory parts and the subdomain was not directing to the new url either.
There is no /directory string in my code example. HTTP_HOST contains only host name without path information, so you need to omit the /directory.