undefined
Skip to content
Moz logo Menu open Menu close
  • Products
    • Moz Pro
    • Moz Pro Home
    • Moz Local
    • Moz Local Home
    • STAT
    • Moz API
    • Moz API Home
    • Compare SEO Products
    • Moz Data
  • Free SEO Tools
    • Domain Analysis
    • Keyword Explorer
    • Link Explorer
    • Competitive Research
    • MozBar
    • More Free SEO Tools
  • Learn SEO
    • Beginner's Guide to SEO
    • SEO Learning Center
    • Moz Academy
    • MozCon
    • Webinars, Whitepapers, & Guides
  • Blog
  • Why Moz
    • Digital Marketers
    • Agency Solutions
    • Enterprise Solutions
    • Small Business Solutions
    • The Moz Story
    • New Releases
  • Log in
  • Log out
  • Products
    • Moz Pro

      Your all-in-one suite of SEO essentials.

    • Moz Local

      Raise your local SEO visibility with complete local SEO management.

    • STAT

      SERP tracking and analytics for enterprise SEO experts.

    • Moz API

      Power your SEO with our index of over 44 trillion links.

    • Compare SEO Products

      See which Moz SEO solution best meets your business needs.

    • Moz Data

      Power your SEO strategy & AI models with custom data solutions.

    Let your business shine with Listings AI
    Moz Local

    Let your business shine with Listings AI

    Learn more
  • Free SEO Tools
    • Domain Analysis

      Get top competitive SEO metrics like DA, top pages and more.

    • Keyword Explorer

      Find traffic-driving keywords with our 1.25 billion+ keyword index.

    • Link Explorer

      Explore over 40 trillion links for powerful backlink data.

    • Competitive Research

      Uncover valuable insights on your organic search competitors.

    • MozBar

      See top SEO metrics for free as you browse the web.

    • More Free SEO Tools

      Explore all the free SEO tools Moz has to offer.

    NEW Keyword Suggestions by Topic
    Moz Pro

    NEW Keyword Suggestions by Topic

    Learn more
  • Learn SEO
    • Beginner's Guide to SEO

      The #1 most popular introduction to SEO, trusted by millions.

    • SEO Learning Center

      Broaden your knowledge with SEO resources for all skill levels.

    • On-Demand Webinars

      Learn modern SEO best practices from industry experts.

    • How-To Guides

      Step-by-step guides to search success from the authority on SEO.

    • Moz Academy

      Upskill and get certified with on-demand courses & certifications.

    • MozCon

      Save on Early Bird tickets and join us in London or New York City

    Unlock flexible pricing & new endpoints
    Moz API

    Unlock flexible pricing & new endpoints

    Find your plan
  • Blog
  • Why Moz
    • Digital Marketers

      Simplify SEO tasks to save time and grow your traffic.

    • Small Business Solutions

      Uncover insights to make smarter marketing decisions in less time.

    • Agency Solutions

      Earn & keep valuable clients with unparalleled data & insights.

    • Enterprise Solutions

      Gain a competitive edge in the ever-changing world of search.

    • The Moz Story

      Moz was the first & remains the most trusted SEO company.

    • New Releases

      Get the scoop on the latest and greatest from Moz.

    Surface actionable competitive intel
    New Feature

    Surface actionable competitive intel

    Learn More
  • Log in
    • Moz Pro
    • Moz Local
    • Moz Local Dashboard
    • Moz API
    • Moz API Dashboard
    • Moz Academy
  • Avatar
    • Moz Home
    • Notifications
    • Account & Billing
    • Manage Users
    • Community Profile
    • My Q&A
    • My Videos
    • Log Out

The Moz Q&A Forum

  • Forum
  • Questions
  • Users
  • Ask the Community

Welcome to the Q&A Forum

Browse the forum for helpful insights and fresh discussions about all things SEO.

  1. Home
  2. SEO Tactics
  3. Technical SEO
  4. What is the best method to block a sub-domain, e.g. staging.domain.com/ from getting indexed?

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.

What is the best method to block a sub-domain, e.g. staging.domain.com/ from getting indexed?

Technical SEO
4
13
7.9k
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as question
Log in to reply
This topic has been deleted. Only users with question management privileges can see it.
  • fthead9
    fthead9 last edited by Oct 5, 2011, 7:23 PM

    Now that Google considers subdomains as part of the TLD I'm a little leery of testing robots.txt with something like:

    staging.domain.com
    User-agent: *
    Disallow: /

    in fear it might get the www.domain.com blocked as well. Has anyone had any success using robots.txt to block sub-domains? I know I could add a meta robots tag to the staging.domain.com pages but that would require a lot more work.

    1 Reply Last reply Reply Quote 0
    • KeriMorgret
      KeriMorgret @RyanKent last edited by Oct 10, 2011, 7:53 PM Oct 6, 2011, 10:55 PM

      Just make sure that when/if you copy over the staging site to the live domain that you don't copy over the robots.txt, htaccess, or whatever means you use to block that site from being indexed and thus have your shiny new site be blocked. 🙂

      1 Reply Last reply Reply Quote 1
      • RyanKent
        RyanKent @RyanKent last edited by Oct 5, 2011, 9:46 PM Oct 5, 2011, 9:46 PM

        I agree. The name of your subdomain being "staging" didn't register at all with me until Matt brought it up. I was offering a generic response to the subdomain question whereas I believe Matt focused on how to handle a staging site. Interesting viewpoint.

        1 Reply Last reply Reply Quote 0
        • fthead9
          fthead9 @RyanKent last edited by Oct 5, 2011, 9:00 PM Oct 5, 2011, 9:00 PM

          Matt/Ryan-

          Great discussion, thanks for the input. The staging.domain.com is just one of the domains we don't want indexed. Some of them still need to be accessed by the public, some like staging could be restricted to specific IPs.

          I realize after your discussion I probably should have used a different example of a sub-domain. On the other hand it might not have sparked the discussion so maybe it was a good example 😉

          1 Reply Last reply Reply Quote 0
          • bloggidy
            bloggidy @RyanKent last edited by Oct 5, 2011, 8:34 PM Oct 5, 2011, 8:34 PM

            .htaccess files can be placed at any directory level of a site so you can do it for just the subdomain or even just a directory of a domain.

            1 Reply Last reply Reply Quote 1
            • bloggidy
              bloggidy @fthead9 last edited by Oct 5, 2011, 8:33 PM Oct 5, 2011, 8:33 PM

              Staging URL's are typically only used for testing so rather than do a deny I would recommend using a specific ALLOW for only the IP addresses that should be allowed access.

              I would imagine you don't want it indexed because you don't want the rest of the world knowing about it.

              You can also use HTACCESS to use username/passwords. It is simple but you can give that to clients if that is a concern/need.

              1 Reply Last reply Reply Quote 0
              • RyanKent
                RyanKent @fthead9 last edited by Oct 5, 2011, 8:25 PM Oct 5, 2011, 8:25 PM

                Correct.

                1 Reply Last reply Reply Quote 0
                • RyanKent
                  RyanKent @fthead9 last edited by Oct 5, 2011, 8:24 PM Oct 5, 2011, 8:24 PM

                  Toren, I would not recommend that solution. There is nothing to prevent Googlebot from crawling your site via almost any IP. If you found 100 IPs used by the crawler and blocked them all, there is nothing to stop the crawler from using IP #101 next month. Once the subdomain's content is located and indexed, it will be a headache fixing the issue.

                  The best solution is always going to be a noindex meta tag on the pages you do not wish to be indexed. If that method is too much work or otherwise undesirable, you can use the robots.txt solution. There is no circumstance I can imagine where you would modify your htaccess file to block googlebot.

                  1 Reply Last reply Reply Quote 1
                  • RyanKent
                    RyanKent @bloggidy last edited by Oct 5, 2011, 8:21 PM Oct 5, 2011, 8:21 PM

                    Hi Matt.

                    Perhaps I misunderstood the question but I believe Toren only wishes to prevent the subdomain from being indexed. If you restrict subdomain access by IP it would prevent visitors from accessing the content which I don't believe is the goal.

                    bloggidy fthead9 RyanKent KeriMorgret 4 Replies Last reply Oct 6, 2011, 10:55 PM Reply Quote 1
                    • fthead9
                      fthead9 @bloggidy last edited by Oct 5, 2011, 8:19 PM Oct 5, 2011, 8:19 PM

                      Interesting, hadn't thought of using htaccess to block Googlebot.Thanks for the suggestion.

                      RyanKent bloggidy 2 Replies Last reply Oct 5, 2011, 8:33 PM Reply Quote 0
                      • fthead9
                        fthead9 @RyanKent last edited by Oct 5, 2011, 8:18 PM Oct 5, 2011, 8:18 PM

                        Thanks Ryan. So you don't see any issues with de-indexing the main site if I created a second robots.txt file, e.g.

                        http://staging.domin.com/robots.txt

                        User-agent: *
                        Disallow: /

                        That was my initial thought but when Google announced they consider sub-domains part of the TLD I was afraid it might affect the htp://www.domain.com versions of the pages. So you're saying the subdomain is basically treated like a folder you block on the primary domain?

                        RyanKent 1 Reply Last reply Oct 5, 2011, 8:25 PM Reply Quote 0
                        • bloggidy
                          bloggidy last edited by Oct 5, 2011, 9:01 PM Oct 5, 2011, 8:07 PM

                          Use an .htaccess file to only allow from certain ip addresses or ranges.

                          Here is an article describing how: http://www.kirupa.com/html5/htaccess_tricks.htm

                          fthead9 RyanKent 2 Replies Last reply Oct 5, 2011, 8:21 PM Reply Quote 1
                          • RyanKent
                            RyanKent last edited by Oct 5, 2011, 9:01 PM Oct 5, 2011, 7:40 PM

                            What is the best method to block a sub-domain, e.g. staging.domain.com/ from getting indexed?

                            Place a robots.txt file in the root of the subdomain.

                            User-agent: *
                            Disallow: /

                            This method will block the subdomain while leaving your primary domain unaffected.

                            fthead9 1 Reply Last reply Oct 5, 2011, 8:18 PM Reply Quote 2
                            • 1 / 1
                            1 out of 13
                            • First post
                              1/13
                              Last post

                            Got a burning SEO question?

                            Subscribe to Moz Pro to gain full access to Q&A, answer questions, and ask your own.


                            Start my free trial


                            Browse Questions

                            Explore more categories

                            • Moz Tools

                              Chat with the community about the Moz tools.

                            • SEO Tactics

                              Discuss the SEO process with fellow marketers

                            • Community

                              Discuss industry events, jobs, and news!

                            • Digital Marketing

                              Chat about tactics outside of SEO

                            • Research & Trends

                              Dive into research and trends in the search industry.

                            • Support

                              Connect on product support and feature requests.

                            • See all categories

                            Related Questions

                            • iQi

                              Google is still indexing the old domain a year after 301 redirects are put in place

                              Hi there, You might have experienced this before but for me this is the first. A client of mine moved from domain A (www.domainA.com) to domain B (www.domainB.com). 301 redirects are all in place for over a year. But the old domain is still showing in Google when you search for "site:domainA.com" The HTTP Header check shows this result for the URL https://www.domainA.com/company/cookie-policy.aspx HTTP/1.1 301 Moved Permanently => 
                              Cache-Control => private
                              Content-Length => 174
                              Content-Type => text/html; charset=utf-8
                              Location => https://www.domain_B_.com/legal/cookie-policy
                              Server => Microsoft-IIS/10.0
                              X-AspNetMvc-Version => 5.2
                              X-AspNet-Version => 4.0.30319
                              X-Powered-By => ASP.NET
                              Date => Fri, 15 Mar 2019 12:01:33 GMT
                              Connection => close Does the redirect look wrong? The change of address request was made on Google Console when the website was moved over a year ago. Edit: Checked the domainA.com on bing and it seems that its not indexed, and replaced with domainB.com, which is the right. Just Google is indexing the old domain! Please let me know your thoughts on why this is happening. Best,

                              Technical SEO | Mar 22, 2019, 6:45 PM | iQi
                              0
                            • arun.negi

                              We switched the domain from www.blog.domain.com to domain.com/blog.

                              We switched the domain from www.blog.domain.com to domain.com/blog. This was done with the purpose of gaining backlinks to our main website as well along with to our blog. This set us very low in organic traffic and not to mention, lost the backlinks. For anything, they are being redirected to 301 code. Kindly suggest changes to bring back all the traffic.

                              Technical SEO | Nov 12, 2017, 10:15 AM | arun.negi
                              0
                            • ccox1

                              My Homepage Won't Load if Javascript is Disabled. Is this an SEO/Indexation issue?

                              Hi everyone, I'm working with a client who recently had their site redesigned. I'm just going through to do an initial audit to make sure everything looks good. Part of my initial indexation audit goes through questions about how the site functions when you disable, javascript, cookies, and/or css. I use the Web Developer extension for Chrome to do this. I know, more recently, people have said that content loaded by Javascript will be indexed. I just want to make sure it's not hurting my clients SEO. http://americasinstantsigns.com/ Is it as simple as looking at Google's Cached URL? The URL is definitely being indexed and when looking at the text-only version everything appears to be in order. This may be an outdated question, but I just want to be sure! Thank you so much!

                              Technical SEO | Jul 28, 2016, 12:43 PM | ccox1
                              0
                            • HeroDesignStudio

                              Should a sub domain be a separate property in the Search Console?

                              We're launching a blog on a sub-domain of a corp site (blog.corpsite.com). We already have corpsite.com set up in the Search Console. Should I set up a separate property for this sub-domain in the Search Console (WMT) in order to manage it? Is it necessary? Thanks, JM

                              Technical SEO | Aug 24, 2015, 3:51 PM | HeroDesignStudio
                              0
                            • CharmingGuy

                              How to block text on a page to be indexed?

                              I would like to block the spider indexing a block of text inside a page , however I do not want to block the whole page with, for example , a noindex tag. I have tried already with a tag like this : chocolate pudding chocolate pudding However this is not working for my case, a travel related website. thanks in advance for your support. Best regards Gianluca

                              Technical SEO | Feb 16, 2014, 11:25 PM | CharmingGuy
                              0
                            • FranFerrara

                              Why do some URLs for a specific client have "/index.shtml"?

                              Reviewing our client's URLs for a 301 redirect strategy, we have noticed that many URLs have "/index.shtml." The part we don'd understand is these URLs aren't the homepage and they have multiple folders followed by "/index.shtml" Does anyone happen to know why this may be occurring? Is there any SEO value in keeping the "/index.shtml" in the URL?

                              Technical SEO | Jan 15, 2014, 7:18 PM | FranFerrara
                              0
                            • Clicksjim

                              WordPress - How to stop both http:// and https:// pages being indexed?

                              Just published a static page 2 days ago on WordPress site but noticed that Google has indexed both http:// and https:// url's. Usually I only get http:// indexed though. Could anyone please explain why this may have happened and how I can fix? Thanks!

                              Technical SEO | Jan 10, 2013, 7:02 PM | Clicksjim
                              1
                            • sboelter

                              Multiple Domains, Same IP address, redirecting to preferred domain (301) -site is still indexed under wrong domains

                              Due to acquisitions over time and the merging of many microsites into one major site, we currently have 20+ TLD's  pointing to the same IP address as our "preferred domain:"  for our consolidated website http://goo.gl/gH33w. They are all set up as 301 redirects on apache - including both the www and non www versions. When we launched this consolidated website, (April 2010) we accidentally left the settings of our site open to accept any of our domains on the same IP.  This was later fixed but unfortunately Google indexed our site under multiple of these URL's (ignoring the redirects) using the same content from our main website but swapping out the domain.  We added some additional redirects on apache to redirect these individual pages pages indexed under the wrong domain to the same page under our main domain http://goo.gl/gH33w.  This seemed to help resolve the issue and moved hundreds of pages off the index.  However, in December of 2010 we made significant changes in our external dns for our ip addresses and now since December, we see pages indexed under these redirecting domains on the rise again. If you do a search query of : site:laboratoryid.com you will see a few hundred examples of pages indexed under the wrong domain.  When you click on the link, it does redirect to the same page but under the preferred domain.  So the redirect is working and has been confirmed as 301.  But for some reason Google continues to crawl our site and index under this incorrect domains.  Why is this? Is there a setting we are missing?   These domain level and page level redirects should be decreasing the pages being indexed under the wrong domain but it appears it is doing the reverse. All of these old domains currently point to our production IP address where are preferred domain is also pointing.  Could this be the issue? None of the pages indexed today are from the old version of these sites. They only seem to be the new content from the new site but not under the preferred domain. Any insight would be much appreciated because we have tried many things without success to get this resolved.

                              Technical SEO | Jun 2, 2011, 3:45 PM | sboelter
                              0

                            Get started with Moz Pro!

                            Unlock the power of advanced SEO tools and data-driven insights.

                            Start my free trial
                            Products
                            • Moz Pro
                            • Moz Local
                            • Moz API
                            • Moz Data
                            • STAT
                            • Product Updates
                            Moz Solutions
                            • SMB Solutions
                            • Agency Solutions
                            • Enterprise Solutions
                            • Digital Marketers
                            Free SEO Tools
                            • Domain Authority Checker
                            • Link Explorer
                            • Keyword Explorer
                            • Competitive Research
                            • Brand Authority Checker
                            • Local Citation Checker
                            • MozBar Extension
                            • MozCast
                            Resources
                            • Blog
                            • SEO Learning Center
                            • Help Hub
                            • Beginner's Guide to SEO
                            • How-to Guides
                            • Moz Academy
                            • API Docs
                            About Moz
                            • About
                            • Team
                            • Careers
                            • Contact
                            Why Moz
                            • Case Studies
                            • Testimonials
                            Get Involved
                            • Become an Affiliate
                            • MozCon
                            • Webinars
                            • Practical Marketer Series
                            • MozPod
                            Connect with us

                            Contact the Help team

                            Join our newsletter
                            Moz logo
                            © 2021 - 2025 SEOMoz, Inc., a Ziff Davis company. All rights reserved. Moz is a registered trademark of SEOMoz, Inc.
                            • Accessibility
                            • Terms of Use
                            • Privacy

                            Looks like your connection to Moz was lost, please wait while we try to reconnect.