How to prevent seach engine to index your subdomains

I was so pissed with my host that this could happen. I am not talking about preventing the Google and other seach engine to index our subdomain if we want it to. 

For example, we could have a subdomain like this    blog.universal.com and we want the search engine to index this. So google bot comes and index all pages inside that subdomain for example

http://blog.universal.com/our_goals

http://blog.universal.com/memories

http://blog.universal.com/what_we_have_done

http://blog.universal.com/...........etc

That is all good. I am talking about a different scenario that can be disastrous for our SEO status. 

On shared hosting, talking about cheap ass hosting, we have one main domain for each hosting account. If we want to host more domains, we just sign them up as addon domains. That means that each addon domain will be placed in the subfolder of the main domain. 

So we have main domain files in our public_html folder on our server. Each addon domain will be placed inside the folderinside of public_html folder. 

We have like public_html/maindomain/subfolderofaddondomain

In this case ou,r main domain is for example universal.com. We want to build another site lets say it is called specific.com. 

The addon domain files will be in the folder placed in our universal.com domain folder. 

But here comes trouble. Each addon domain can be accessed in many ways. We can get to the domain by typing addoncomainfolder-maindomain.com or maindomain.com/addondomainfolder etc.....

Sometimes when Google bot is drunk it will index our add-on domain in 2 ways. SO we face duplicate content. 

We will see in Google results the same article but from 2 different domains

1. specific.universal.com/article1

2.specific.com/article1

 

As you can see this is the same content but indexed from 2 different locations. And we got duplicate content. We do not want that. Because Google can easily penalize us. We need to prevent search engines to access and index our site through

addondomain.maindomain.com and prevent having trouble. And btw who want to see that these two domains are connected in some way?

What you can do to check if this has happened on your account is type this in Google

site:maindomain.com so it would be in my case  site:universal.com

Then you can see all the pages, that were cached by Google. You can see if you experience the problem of having addondomain.maindomain.com pages indexed. 

If that happend you can go to webmasters account in Google, add your site and ask google to remove these pages from index. 

The link is here

https://www.google.com/webmasters/tools/removals?pli=1    I advice you to use this link directly and not going into webmaster tools and click on removal link because on that page you will not be able to add addomdomain.maindomain.com type of links but only maindomain.com links. I know that is weird but just use my link. 

If you experience problem yourself we can help you delete al wrongly indexed urls for a fee. Contant us. 

SO to prevent this in the future you need to put this in the -htaccess file of your subdomain(addondomain) folder.

PUT ONE OF THE codes AT THE END OF YOUR HTACCESS DOCUMENT IN THE SUBFOLDER OF PUBLIC HTML

RewriteEngine On
        RewriteCond %{HTTP_HOST} ^subdomain.primarydomain.com$ [OR]
        RewriteCond %{HTTP_HOST} ^www.subdomain.primarydomain.com$ [OR]
        RewriteCond %{HTTP_HOST} ^addondomain.com$
        RewriteCond %{REQUEST_URI} ^/$
        RewriteRule ^(.*)$ http://www.addondomain.com/ [R=301,L]

With this code you prevent Google and other search engines to index your subdomain.maindomain.com pages and prevent being penalized for duplicate content.

Another code would be 

 

# Conditions to check for

# If HTTP_HOST

# - ends with rootdomain.org (not case-sensitive)

#    rootdomain\.org$ [NC]

# - AND has zero or more characters between the beginning and altermedicine.org

#    ^(.*)

RewriteCond %{HTTP_HOST} ^(.*)rootdomain\.org$ [NC]


# Rules to apply

# If conditions are met:

# - Redirect the whole thing to the main domain, appending the requested URI to it

RewriteRule ^ http://www.seoandwebdesign.com%{REQUEST_URI} [L,R=301]

 

 

AND THE CODE I AM USING CURRENTLY (WHICH WORKS 2018)

 

#
#CODE START
#

# Conditions to check for

# If HTTP_HOST

# - ends with rootdomain.com (not case-sensitive)

#    rootdomain\.com$ [NC]

# - AND has zero or more characters between the beginning and rootdomain.com

#    ^(.*)

RewriteCond %{HTTP_HOST} ^(.*)rootdomain\.com$ [NC]

# Rules to apply

# If conditions are met:

# - Redirect the whole thing to the main domain, appending the requested URI to it

RewriteCond %{REQUEST_URI} !^/\.well-known/acme-challenge/[0-9a-zA-Z_-]+$

RewriteCond %{REQUEST_URI} !^/\.well-known/cpanel-dcv/[0-9a-zA-Z_-]+$

RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$

RewriteRule ^ http://www.seoandwebdesign.com%{REQUEST_URI} [L,R=301]

#

#CODE END

#

Add new comment

The content of this field is kept private and will not be shown publicly.

Plain text

  • No HTML tags allowed.
  • Web page addresses and email addresses turn into links automatically.
  • Lines and paragraphs break automatically.