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. Technical SEO Issues
    4. Subdomain Removal in Robots.txt with Conditional Logic??

    Subdomain Removal in Robots.txt with Conditional Logic??

    Technical SEO Issues
    3 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.
    • ErnieB
      ErnieB last edited by

      I would like to see if there is a way to add conditional logic to the robots.txt file so that when we push from DEV to PRODUCTION and the robots.txt file is pushed, we don't have to remember to NOT push the robots.txt file OR edit it when it goes live.

      My specific situation is this:

      I have www.website.com, dev.website.com and new.website.com and somehow google has indexed the DEV.website.com and NEW.website.com and I'd like these to be removed from google's index as they are causing duplicate content.

      Should I:

      a) add 2 new GWT entries for DEV.website.com and NEW.website.com and VERIFY ownership - if I do this, then when the files are pushed to LIVE won't the files contain the VERIFY META CODE for the DEV version even though it's now LIVE? (hope that makes sense)

      b) write a robots.txt file that specifies "DISALLOW: DEV.website.com/" is that possible? I have only seen examples of DISALLOW with a "/" in the beginning...

      Hope this makes sense, can really use the help!  I'm on a Windows Server 2008 box running ColdFusion websites.

      1 Reply Last reply Reply Quote 0
      • irvingw
        irvingw last edited by

        you can't put logic in robots.txt and subdomains are seen as different sites, so you need to create separate robots.txt files for each subdomain and block them in their respective robots.txt files.

        You'll need to also add the Google verification code and verify them, then in GWMT you can request to have the subdomain removed from Googles index, that's the fastest way.

        1 Reply Last reply Reply Quote 0
        • KeriMorgret
          KeriMorgret last edited by

          Here's how I dealt with a similar situation in the past.

          Robots.txt on each of the dev subdomains and on the live domain. Dev subdomains robots.txt excluded the entire subdomain, and subdomains were verified in GWT and removed as needed.

          Made live subdomain robots.txt read-only so it didn't get overwritten. Should have made dev subdomains robots.txt read-only as well, since they sometimes got refreshed with the live content (there was a UGC database that would occasionally get copied to a dev subdomain, and we'd have robots.txt get copied over too and dev subdomain indexed).

          Set up a code monitor that checks the contents of all of the robots.txt daily and sends me an email if anything is changed.

          Not perfect, but I was at least able to catch changes soon after they happened, and prevented a few changes.

          1 Reply Last reply Reply Quote 1
          • 1 / 1
          • First post
            Last post
          • Robots.txt on subdomains
            Whittie
            Whittie
            0
            3
            3.5k

          • To Subdomain or Not Subdomain?
            AlanMosley
            AlanMosley
            0
            8
            144

          • Remove remove
            KeriMorgret
            KeriMorgret
            0
            4
            110

          • Do I need robots.txt and meta robots?
            Cyrus-Shepard
            Cyrus-Shepard
            0
            7
            1.1k

          • Robots.txt
            JordanGodbey
            JordanGodbey
            0
            6
            619

          • Robots.txt
            Ontarioseo
            Ontarioseo
            0
            5
            737

          • Robots.txt
            Entrusteddev
            Entrusteddev
            0
            3
            642

          • Subdomain Robots.txt
            JohnECF
            JohnECF
            0
            3
            1.2k

          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