Moz Q&A is closed.
After more than 13 years, and tens of thousands of questions, Moz Q&A closed on 12th December 2024. Whilst we’re not completely removing the content - many posts will still be possible to view - we have locked both new posts and new replies. More details here.
Block an entire subdomain with robots.txt?
- 
					
					
					
					
 Is it possible to block an entire subdomain with robots.txt? I write for a blog that has their root domain as well as a subdomain pointing to the exact same IP. Getting rid of the option is not an option so I'd like to explore other options to avoid duplicate content. Any ideas? 
- 
					
					
					
					
 Awesome! That did the trick -- thanks for your help. The site is no longer listed  
- 
					
					
					
					
 Fact is, the robots file alone will never work (the link has a good explanation why - short form: all it does is stop the bots from indexing again). Best to request removal then wait a few days. 
- 
					
					
					
					
 Yeah. As of yet, the site has not been de-indexed. We placed the conditional rule in htaccess and are getting different robots.txt files for the domain and subdomain -- so that works. But I've never done this before so I don't know how long it's supposed to take? I'll try to verify via Webmaster Tools to speed up the process. Thanks 
- 
					
					
					
					
 You should do a remove request in Google Webmaster Tools. You have to first verify the sub-domain then request the removal. See this post on why the robots file alone won't work... http://www.seomoz.org/blog/robot-access-indexation-restriction-techniques-avoiding-conflicts 
- 
					
					
					
					
 Awesome. We used your second idea and so far it looks like it is working exactly how we want. Thanks for the idea. Will report back to confirm that the subdomain has been de-indexed. 
- 
					
					
					
					
 Option 1 could come with a small performance hit if you have a lot of txt files being used on the server. There shouldn't be any negative side effects to option 2 if the rewrite is clean (IE not accidently a redirect) and the content of the two files are robots compliant. Good luck 
- 
					
					
					
					
 Thanks for the suggestion. I'll definitely have to do a bit more research into this one to make sure that it doesn't have any negative side effects before implementation 
- 
					
					
					
					
 We have a plugin right now that places canonical tags, but unfortunately, the canonical for the subdomain points to the subdomain. I'll look around to see if I can tweak the settings 
- 
					
					
					
					
 Sounds like (from other discussions) you may be stuck requiring a dynamic robot.txt file which detects what domain the bot is on and changes the content accordingly. This means the server has to run all .txt file as (I presume) PHP. Or, you could conditionally rewrite the /robot.txt URL to a new file according to sub-domain RewriteEngine on 
 RewriteCond %{HTTP_HOST} ^subdomain.website.com$
 RewriteRule ^robotx.txt$ robots-subdomain.txtThen add: User-agent: * 
 Disallow: /to the robots-subdomain.txt file (untested) 
- 
					
					
					
					
 Placing canonical tags isn't an option? Detect that the page is being viewed through the subdomain, and if so, write the canonical tag on the page back to the root domain? Or, just place a canonical tag on every page pointing back to the root domain (so the subdomain and root domain pages would both have them). Apparently, it's ok to have a canonical tag on a page pointing to itself. I haven't tried this, but if Matt Cutts says it's ok... 
- 
					
					
					
					
 Hey Ryan, I wasn't directly involved with the decision to create the subdomain, but I'm told that it is necessary to create in order to bypass certain elements that were affecting the root domain. Nevertheless, it is a blog and the users now need to login to the subdomain in order to access the Wordpress backend to bypass those elements. Traffic for the site still goes to the root domain. 
- 
					
					
					
					
 They both point to the same location on the server? So there's not a different folder for the subdomain? If that's the case then I suggest adding a rule to your htaccess file to 301 the subdomain back to the main domain in exactly the same way people redirect from non-www to www or vice-versa. However, you should ask why the server is configured to have a duplicate subdomain? You might just edit your apache settings to get rid of that subdomain (usually done through a cpanel interface). Here is what your htaccess might look like: <ifmodule mod_rewrite.c="">RewriteEngine on 
 # Redirect non-www to wwww
 RewriteCond %{HTTP_HOST} !^www.mydomain.org [NC]
 RewriteRule ^(.*)$ http://www.mydomain.org/$1 [R=301,L]</ifmodule>
- 
					
					
					
					
 Not to me LOL  I think you'll need someone with a bit more expertise in this area than I to assist in this case. Kyle, I'm sorry I couldn't offer more assistance... but I don't want to tell you something if I'm not 100% sure. I suspect one of the many bright SEOmozer's will quickly come to the rescue on this one. I think you'll need someone with a bit more expertise in this area than I to assist in this case. Kyle, I'm sorry I couldn't offer more assistance... but I don't want to tell you something if I'm not 100% sure. I suspect one of the many bright SEOmozer's will quickly come to the rescue on this one.Andy  
- 
					
					
					
					
 Hey Andy, Herein lies the problem. Since the domain and subdomain point to the exact same place, they both utilize the same robots.txt file. Does that make sense? 
- 
					
					
					
					
 Hi Kyle  Yes, you can block an entire subdomain via robots.txt, however you'll need to create a robots.txt file and place it in the root of the subdomain, then add the code to direct the bots to stay away from the entire subdomain's content. Yes, you can block an entire subdomain via robots.txt, however you'll need to create a robots.txt file and place it in the root of the subdomain, then add the code to direct the bots to stay away from the entire subdomain's content.User-agent: * 
 Disallow: /hope this helps  
Browse Questions
Explore more categories
- 
		
		Moz ToolsChat with the community about the Moz tools. 
- 
		
		SEO TacticsDiscuss the SEO process with fellow marketers 
- 
		
		CommunityDiscuss industry events, jobs, and news! 
- 
		
		Digital MarketingChat about tactics outside of SEO 
- 
		
		Research & TrendsDive into research and trends in the search industry. 
- 
		
		SupportConnect on product support and feature requests. 
Related Questions
- 
		
		
		
		
		
		Block session id URLs with robots.txt
 Hi, I would like to block all URLs with the parameter '?filter=' from being crawled by including them in the robots.txt. Which directive should I use: User-agent: * Intermediate & Advanced SEO | | Mat_C
 Disallow: ?filter= or User-agent: *
 Disallow: /?filter= In other words, is the forward slash in the beginning of the disallow directive necessary? Thanks!1
- 
		
		
		
		
		
		Can subdomains hurt your primary domain's SEO?
 Our primary website https://domain.com has a subdomain https://subDomain.domain.com and on that subdomain we have a jive-hosted community, with a few links to and fro. In GA they are set up as different properties but there are many SEO issues in the jive-hosted site, in which many different people can create content, delete content, comment, etc. There are issues related to how jive structures content, broken links, etc. My question is this: Aside from the SEO issues with the subdomain, can the performance of that subdomain negatively impact the SEO performance and rank of the primary domain? I've heard and read conflicting reports about this and it would be nice to hear from the MOZ community about options to resolve such issues if they exist. Thanks. Intermediate & Advanced SEO | | BHeffernan1
- 
		
		
		
		
		
		No index detected in robots meta tag GSC issue_Help Please
 Hi Everyone, We just did a site migration ( URL structure change, site redesign, CMS change). During migration, dev team messed up badly on a few things including SEO. The old site had pages canonicalized and self canonicalized <> New site doesn't have anything (CMS dev error) so we are working retroactively to add canonicalization mechanism The legacy site had URL’s ending with a trailing slash “/” <> new site got redirected to Set of url’s without “/” New site action : All robots are allowed: A new sitemap is submitted to google search console So here is my problem (it been a long 24hr night for me 🙂 ) 1. Now when I look at GSC homepage URL it says that old page is self canonicalized and currently in index (old page with a trailing slash at the end of URL). 2. When I try to perform a live URL test, I get the message "No: 'noindex' detected in 'robots' meta tag" , so indexation cant be done. I have no idea where noindex is coming from. 3. Robots.txt in search console still showing old file ( no noindex there ) I tried to submit new file but old one still coming up. When I click on "See live robots.txt" I get current robots. 4. I see that old page is still canonicalized and attempting to index redirected old page might be confusing google Hope someone can help to get the new page indexed! I really need it 🙂 Please ping me if you need more clarification. Thank you ! Thank you Intermediate & Advanced SEO | | bgvsiteadmin1
- 
		
		
		
		
		
		Can subdomains avoid spam penalizations?
 Hello everyone, I have a basic question for which I couldn't find a definitive answer for. Let's say I have my main website with URL: www.mywebsite.com And I have a related affiliates website with URL: affiliates.mywebsite.com Which includes completely different content from the main website. Also, both domains have two different IP addresses. Are those considered two completely separate domains by Google? Can bad links pointing to affiliates.mywebsite.com affect www.mywebsite.com in any way? Thanks in advance for any answer to my inquiry! Intermediate & Advanced SEO | | fablau0
- 
		
		
		
		
		
		"noindex, follow" or "robots.txt" for thin content pages
 Does anyone have any testing evidence what is better to use for pages with thin content, yet important pages to keep on a website? I am referring to content shared across multiple websites (such as e-commerce, real estate etc). Imagine a website with 300 high quality pages indexed and 5,000 thin product type pages, which are pages that would not generate relevant search traffic. Question goes: Does the interlinking value achieved by "noindex, follow" outweigh the negative of Google having to crawl all those "noindex" pages? With robots.txt one has Google's crawling focus on just the important pages that are indexed and that may give ranking a boost. Any experiments with insight to this would be great. I do get the story about "make the pages unique", "get customer reviews and comments" etc....but the above question is the important question here. Intermediate & Advanced SEO | | khi50
- 
		
		
		
		
		
		301 Redirect of subdomain?
 Fellow Mozzers, I'm having a hard time wrapping my brain around a redirect issue and thought it was worth posing the question to the Moz community. I did a search first but couldn't find the exact answer I was looking for. How does a 301 redirect work when you redirect a sub domain example.homepage.com to www.homepage.com but you keep the sub directories of example.homepage.com/page-1 active and are trying to rank them? I'm dealing with a current project where this is happening and this doesn't make sense to me, to redirect the subdomain if you're also trying to rank/create search traffic for pages, sub directories on example.homepage.com. This also get's into the debate of if a sub domain site is viewed as it's own website and therefore has to rank itself. If this is true, it seems like we're kind of killing the authority of the site by redirecting it. Additionally, www.homepage.com has a much stronger link profile than example.homepage.com I hope this makes sense. Any thoughts are appreciated. Thanks for your time. Intermediate & Advanced SEO | | SMG-Texas0
- 
		
		
		
		
		
		Best way to block a sub-domain from being indexed
 Hello, The search engines have indexed a sub-domain I did not want indexed its on old.domain.com and dev.domain.com - I was going to password them but is there a best practice way to block them. My main domain default robots.txt says :- Sitemap: http://www.domain.com/sitemap.xml global User-agent: * Intermediate & Advanced SEO | | JohnW-UK
 Disallow: /cgi-bin/
 Disallow: /wp-admin/
 Disallow: /wp-includes/
 Disallow: /wp-content/plugins/
 Disallow: /wp-content/cache/
 Disallow: /wp-content/themes/
 Disallow: /trackback/
 Disallow: /feed/
 Disallow: /comments/
 Disallow: /category//
 Disallow: */trackback/
 Disallow: */feed/
 Disallow: /comments/
 Disallow: /?0
- 
		
		
		
		
		
		Duplicate content on subdomains.
 Hi Mozer's, I have a site www.xyz.com and also geo targeted sub domains www.uk.xyz.com, www.india.xyz.com and so on. All the sub domains have the content which is same as the content on the main domain that is www.xyz.com. So, I want to know how can i avoid content duplication. Many Thanks! Intermediate & Advanced SEO | | HiteshBharucha0
 
			
		 
			
		 
			
		 
			
		 
					
				 
					
				 
					
				 
					
				 
					
				