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
    • SEO Q&A
    • Webinars, Whitepapers, & Guides
  • Blog
  • Why Moz
    • Agency Solutions
    • Enterprise Solutions
    • Small Business Solutions
    • Case Studies
    • 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.

    NEW Keyword Suggestions by Topic
    Moz Pro

    NEW Keyword Suggestions by Topic

    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
    • 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.

    • Case Studies

      Explore how Moz drives ROI with a proven track record of success.

    • 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.8k
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

                            • fbcosta

                              How to index e-commerce marketplace product pages

                              technical seo ecommerce indexation crawl product page

                              Hello! We are an online marketplace that submitted our sitemap through Google Search Console 2 weeks ago. Although the sitemap has been submitted successfully, out of ~10000 links (we have ~10000 product pages), we only have 25 that have been indexed. I've attached images of the reasons given for not indexing the platform. gsc-dashboard-1 gsc-dashboard-2 How would we go about fixing this?

                              Technical SEO | Mar 4, 2024, 10:20 AM | fbcosta
                              0
                            • CarlLarson

                              What are best options for website built with navigation drop-down menus in JavaScript, to get those menus indexed by Google?

                              This concerns f5.com, a large website with navigation menus that drop down when hovered over. The sub nav items (example: “DDoS Protection”) are not cached by Google and therefore do not distribute internal links properly to help those sub-pages rank well. Best option naturally is to change the nav menus from JS to CSS but barring that, is there another option? Will Schema SiteNavigationElement work as an alternate?

                              Technical SEO | Feb 16, 2017, 6:03 PM | CarlLarson
                              0
                            • zasite

                              Do URLs with canonical tags get indexed by Google?

                              Hi, we re-branded and launched a new website in February 2016. In June we saw a steep drop in the number of URLs indexed, and there have continued to be smaller dips since. We started an account with Moz and found several thousand high priority crawl errors for duplicate pages and have since fixed those with canonical tags. However, we are still seeing the number of URLs indexed drop. Do URLs with canonical tags get indexed by Google? I can't seem to find a definitive answer on this. A good portion of our URLs have canonical tags because they are just events with different dates, but otherwise the content of the page is the same.

                              Technical SEO | Oct 18, 2016, 4:15 PM | zasite
                              0
                            • Kusanagi17

                              Exact Match Domain & Title Tag / URL

                              I currently own an exact match domain for my keyword.  I have it set up with multiple pages and also a blog.   The home page essentially serves as a hub and contains links to all the pages and the blog. My targeted keyword is on its own page and I made the title tag the same as my keyword. As an example the URL for my targeted post looks like this: benefitsofrunningshoes.com/benefits-of-running-shoes I have solid, non-spammy content and clean whitehat earned backlinks directing to that specific page. My concern right now is that the URL looks kinda spammy.  The website has been live for about a week and the home page ranks well enough but my targeted page is no where to be found.  (it does show up if I manually search via search command "site:benefitsofrunningshoes.com"). I'm wondering if it is acceptable to use the exact keyword in title tag / page url if it is also in the domain as an EMD? Should I change the title tag and leave the URL in?  Or should I completely change the title tag and URL and 301 redirect to the new page?  I appreciate any help!

                              Technical SEO | Jun 7, 2015, 2:20 PM | Kusanagi17
                              0
                            • RoxBrock

                              Do I use /es/, /mx/ or /es-mx/ for my Spanish site for Mexico only

                              I currently have the Spanish version of my site under myurl.com/es/ When I was at Pubcon in Vegas last year a panel reviewed my site and said the Spanish version should be in /mx/ rather than /es/ since es is for Spain only and my site is for Mexico only. Today while trying to find information on the web I found /es-mx/ as a possibility. I am changing my site and was planning to change to /mx/ but want confirmation on the correct way to do this. Does anyone have a link to Google documentation that will tell me for sure what to use here? The documentation I read led me to the /es/ but I cannot find that now.

                              Technical SEO | Mar 18, 2014, 2:53 PM | RoxBrock
                              0
                            • melen

                              Staging site and "live" site have both been indexed by Google

                              While creating a site we forgot to password protect the staging site while it was being built.  Now that the site has been moved to the new domain, it has come to my attention that both the staging site (site.staging.com) and the "live" site (site.com) are both being indexed.  What is the best way to solve this problem?  I was thinking about adding a 301 redirect from the staging site to the live site via HTACCESS. Any recommendations?

                              Technical SEO | Sep 16, 2013, 6:51 PM | melen
                              0
                            • rahulchowdhury

                              Unnecessary pages getting indexed in Google for my blog

                              I have a blog dapazze.com and I am suffering from a problem for a long time. I found out that Google have indexed hundreds of replytocom links and images attachment pages for my blog. I had to remove these pages manually using the URL removal tool. I had used "Disallow: ?replytocom" in my robots.txt, but Google disobeyed it. After that, I removed the parameter from my blog completely using the SEO by Yoast plugin. But now I see that Google has again started indexing these links even after they are not present in my blog (I use #comment). Google have also indexed many of my admin and plugin pages, whereas they are disallowed in my robots.txt file. Have a look at my robots.txt file here: http://dapazze.com/robots.txt Please help me out to solve this problem permanently?

                              Technical SEO | Mar 13, 2013, 3:49 AM | rahulchowdhury
                              0
                            • Grenadi

                              How to 301 multiple domain names to a single domain

                              Hey, I tried to find and answer to this seemingly simple question, but no luck. So, I have one domain name with a website attached to it. I also registered all the other domain names that are similar to it or have different extensions - I want to redirect all the other domain names to my one main domain name without getting penalised by the big G. It looks like this: www.mainsite.com - this is my main domain I also have www.mainsite.com.au, www.mainsite.org, and www.mainsite.org.au which I all want to just redirect to www.mainsite.com I have been told that the best way to do this is a 301 redirect, but to do that you need to make a CNAME for all the other domains that points to www.mainsite.com. My problem is that I cannot seem to create a CNAME record for http://mainsite.com - I have it working for http://www.mainsite.com but not the non www record. What should I be doing differently? Is it just my DNS provider is useless? Thanks, Anthony

                              Technical SEO | Jan 9, 2012, 1:35 PM | Grenadi
                              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
                            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.