The Moz Q&A Forum

    • Forum
    • Questions
    • My Q&A
    • Users
    • Ask the Community

    Welcome to the Q&A Forum

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

    1. SEO and Digital Marketing Q&A Forum
    2. Categories
    3. Intermediate & Advanced SEO
    4. Robots.txt disallow subdomain

    Robots.txt disallow subdomain

    Intermediate & Advanced SEO
    7 3 1.9k
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as question
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Partouter
      Partouter last edited by

      Hi all,

      I have a development subdomain, which gets copied to the live domain. Because I don't want this dev domain to get crawled, I'd like to implement a robots.txt for this domain only. The problem is that I don't want this robots.txt to disallow the live domain. Is there a way to create a robots.txt for this development subdomain only?

      Thanks in advance!

      1 Reply Last reply Reply Quote 0
      • Theo-NL
        Theo-NL last edited by

        I'm sure there is, but I'm guessing you don't want any human visitors to go to your development subdomain and view what is being done there as well? I'd suggest you either limit the visitors that have access by IP address (thereby effectively blocking out Google in one move) and/or implement a .htpasswd solution where developers can log in with their credentials to your development area (which blocks out Google as well).

        Partouter 1 Reply Last reply Reply Quote 0
        • Partouter
          Partouter @Theo-NL last edited by

          Thanks for your quick reply, Theo. Unfortunately, this htpasswd will also get copied to the live environment, so our websites will get password protected live. Could there be any other solution for this?

          1 Reply Last reply Reply Quote 0
          • Theo-NL
            Theo-NL last edited by

            You could use enviromental variables (for example in your env.ini or config.ini file) that are set to DEVELOPMENT, STAGING, or LIVE based on the appropriate environments the code finds itself in.

            With the exact same code, your website would either be limiting IP addresses (on the development environment) or allow all IP addresses (in the live environment). With this setup you can also set different variables per environment such as the level of detail that is shown in your error reporting, connect to a testing database rather than a live one, etc.

            [this was supposed to be a reply, but I accidentely clicked the wrong button. Hitting 'Delete reply' results in an error.]

            1 Reply Last reply Reply Quote 1
            • oznappies
              oznappies last edited by

              Do you ftp copy one domain to the other? If this is a manual process the excluding the robots.txt that is on the test domain would be as simple as excluding it.

              If you automate the copy and want code to function based on base url address then you could create a Httphandler for robots.txt that delivered a different version based on the request url host in the http request header.

              1 Reply Last reply Reply Quote 1
              • Partouter
                Partouter last edited by

                The copying is a manual process and I don't want any risks for the live environment. A Httphandler for robots.txt could be a solution and I'm going to discuss this with one of our developers. Other suggestions are still welcome of course! 🙂

                oznappies 1 Reply Last reply Reply Quote 0
                • oznappies
                  oznappies @Partouter last edited by

                  I would suggest you talk to the developers as Theo suggests to exclude visitors from your test site.

                  1 Reply Last reply Reply Quote 0
                  • 1 / 1
                  • First post
                    Last post
                  • Robots.txt, Disallow & Indexed-Pages..
                    thekiller99
                    thekiller99
                    0
                    5
                    341

                  • Should I disallow all URL query strings/parameters in Robots.txt?
                    OlegKorneitchouk
                    OlegKorneitchouk
                    0
                    5
                    11.2k

                  • Disallow URLs ENDING with certain values in robots.txt?
                    Andy.Drinkwater
                    Andy.Drinkwater
                    0
                    4
                    1.9k

                  • Block subdomain directory in robots.txt
                    DirkC
                    DirkC
                    0
                    5
                    1.1k

                  • Should I use meta noindex and robots.txt disallow?
                    ntcma
                    ntcma
                    0
                    5
                    923

                  • Robots.txt: Syntax URL to disallow
                    Anti-Alex
                    Anti-Alex
                    0
                    8
                    479

                  • Will disallowing in robots.txt noindex a page?
                    FranckNlemba
                    FranckNlemba
                    0
                    6
                    510

                  • How to Disallow Tag Pages With Robot.txt
                    monster99
                    monster99
                    0
                    6
                    4.0k

                  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 - 2026 SEOMoz, Inc., a Ziff Davis company. All rights reserved. Moz is a registered trademark of SEOMoz, Inc.
                  • Accessibility
                  • Terms of Use
                  • Privacy