• majorAlexa

        See all notifications

        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
        • 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. Home
        2. SEO Tactics
        3. Intermediate & Advanced SEO
        4. Robots.txt: how to exclude sub-directories correctly?

        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.

        Robots.txt: how to exclude sub-directories correctly?

        Intermediate & Advanced SEO
        3
        10
        53116
        Loading More Posts
        • Watching

          Notify me of new replies.
          Show question in unread.

        • Not Watching

          Do not notify me of new replies.
          Show question in unread if category is not ignored.

        • Ignoring

          Do not notify me of new replies.
          Do not show question in unread.

        • Oldest to Newest
        • Newest to Oldest
        • Most Votes
        Reply
        • Reply as question
        Locked
        This topic has been deleted. Only users with question management privileges can see it.
        • fablau
          fablau last edited by

          Hello here,

          I am trying to figure out the correct way to tell SEs to crawls this:

          http://www.mysite.com/directory/

          But not this:

          http://www.mysite.com/directory/sub-directory/

          or this:

          http://www.mysite.com/directory/sub-directory2/sub-directory/...

          But with the fact I have thousands of sub-directories with almost infinite combinations, I can't put the following definitions in a manageable way:

          disallow: /directory/sub-directory/

          disallow: /directory/sub-directory2/

          disallow: /directory/sub-directory/sub-directory/

          disallow: /directory/sub-directory2/subdirectory/

          etc...

          I would end up having thousands of definitions to disallow all the possible sub-directory combinations.

          So, is the following way a correct, better and shorter way to define what I want above:

          allow: /directory/$

          disallow: /directory/*

          Would the above work?

          Any thoughts are very welcome! Thank you in advance.

          Best,

          Fab.

          1 Reply Last reply Reply Quote 1
          • MickEdwards
            MickEdwards @sjunaidali last edited by

            I mentioned both.  You add a meta robots to noindex and remove from the sitemap.

            1 Reply Last reply Reply Quote 0
            • sjunaidali
              sjunaidali @MickEdwards last edited by

              But google is still free to index a link/page even if it is not included in xml sitemap.

              MickEdwards 1 Reply Last reply Reply Quote 0
              • MickEdwards
                MickEdwards @sjunaidali last edited by

                Install Yoast Wordpress SEO plugin and use that to restrict what is indexed and what is allowed in a sitemap.

                sjunaidali 1 Reply Last reply Reply Quote 1
                • sjunaidali
                  sjunaidali @MickEdwards last edited by

                  I am using wordpress, Enfold theme (themeforest).

                  I want some files to be accessed by google, but those should not be indexed.

                  Here is an example: http://prntscr.com/h8918o

                  I have currently blocked some JS directories/files using robots.txt (check screenshot)

                  But due to this I am not able to pass Mobile Friendly Test on Google: http://prntscr.com/h8925z (check screenshot)

                  Is its possible to allow access, but use a tag like noindex in the robots.txt file. Or is there any other way out.

                  MickEdwards 1 Reply Last reply Reply Quote 0
                  • fablau
                    fablau last edited by

                    Yes, everything looks good, Webmaster Tools gave me the expected results with the following directives:

                    allow: /directory/$

                    disallow: /directory/*

                    Which allows this URL:

                    http://www.mysite.com/directory/

                    But doesn't allow the following one:

                    http://www.mysite.com/directory/sub-directory2/...

                    This page also gives an update similar to mine:

                    https://support.google.com/webmasters/answer/156449?hl=en

                    I think I am good! Thanks 🙂

                    1 Reply Last reply Reply Quote 2
                    • fablau
                      fablau last edited by

                      Thank you Michael, it is my understanding then that my idea of doing this:

                      allow: /directory/$

                      disallow: /directory/*

                      Should work just fine. I will test it within Google Webmaster Tools, and let you know if any problems arise.

                      In the meantime if anyone else has more ideas about all this and can confirm me that would be great!

                      Thank you again.

                      1 Reply Last reply Reply Quote 1
                      • MickEdwards
                        MickEdwards @fablau last edited by

                        I've always stuck to Disallow and followed -

                        "This is currently a bit awkward, as there is no "Allow" field. The easy way is to put all files to be disallowed into a separate directory, say "stuff", and leave the one file in the level above this directory:"

                        http://www.robotstxt.org/robotstxt.html

                        From https://developers.google.com/webmasters/control-crawl-index/docs/robots_txt this seems contradictory

                        | /* | equivalent to / | equivalent to / | Equivalent to "/" -- the trailing wildcard is ignored. |

                        I think this post will be very useful  for you - http://a-moz.groupbuyseo.org/community/q/allow-or-disallow-first-in-robots-txt

                        1 Reply Last reply Reply Quote 1
                        • fablau
                          fablau @MickEdwards last edited by

                          Thank you Michael,

                          Google and other SEs actually recognize the "allow:" command:

                          https://developers.google.com/webmasters/control-crawl-index/docs/robots_txt

                          The fact is: if I don't specify that, how can I be sure that the following single command:

                          disallow: /directory/*

                          Doesn't prevent SEs to spider the /directory/ index as I'd like to?

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

                            As long as you dont have directories somewhere in /* that you want indexed then I think that will work.  There is no allow so you don't need the first line just

                            disallow: /directory/*

                            You can test out here- https://support.google.com/webmasters/answer/156449?rd=1

                            fablau sjunaidali 2 Replies Last reply Reply Quote 0
                            • 1 / 1
                            • First post
                              Last post

                            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

                            • kcb8178

                              Sub Domain Usage

                              I see that the gap uses gap.com, oldnavy.gap.com and bananarepublic.gap.com.  Wouldn't a better approach for SEO to have oldnavy.com, bananarepublic.com and gap.com all separate?  Is there any benefit to using the approach of store1.parentcompany.com, store2.parentcompany.com etc?  What are the pros and cons to each?

                              Intermediate & Advanced SEO | | kcb8178
                              0
                            • andyheath

                              Will disallowing URL's in the robots.txt file stop those URL's being indexed by Google

                              I found a lot of duplicate title tags showing in Google Webmaster Tools. When I visited the URL's that these duplicates belonged to, I found that they were just images from a gallery that we didn't particularly want Google to index. There is no benefit to the end user in these image pages being indexed in Google. Our developer has told us that these urls are created by a module and are not "real" pages in the CMS. They would like to add the following to our robots.txt file Disallow: /catalog/product/gallery/ QUESTION: If the these pages are already indexed by Google, will this adjustment to the robots.txt file help to remove the pages from the index? We don't want these pages to be found.

                              Intermediate & Advanced SEO | | andyheath
                              0
                            • vinodh-spintadigital

                              Does having a different sub domain for your Landing Page and Blog affect your overall SEO benefits and Ranking?

                              We have a domain www.spintadigital.com that is hosted with dreamhost and we also have a seperate subdomain blog.spintadigital.com which is hosted in the Ghost platform and we are also using Unbounce landing pages with the sub domain get.spintadigital.com. I wanted to know whether having subdomain like this would affect the traffic metric and ineffect affect the SEO and Rankings of our site.  I think it does not affect the increase in domain authority, but in places like similar web i get different traffic metrics for the different domains.  As far as i can see in many of the metrics these are considered as seperate websites.  We are currently concentrating more on our blogs and wanted to make sure that it does help in the overall domain. We do not have the bandwidth to promote three different websites, and hence need the community's help to understand what is the best option to take this forward.

                              Intermediate & Advanced SEO | | vinodh-spintadigital
                              0
                            • Waismann

                              Different Header on Home Page vs Sub pages

                              Hello, I am an SEO/PPC manager for a company that does a medical detox. You can see the site in question here: http://opiates.com. My question is, I've never heard of it specifically being a problem to have a different header on the home page of the site than on the subpages, but I rarely see it either. Most sites, if i'm not mistaken, use a consistent header across most of the site. However, a person i'm working for now said that she has had other SEO's look at the site (above) and they always say that it is a big SEO problem to have a different header on the homepage than on the subpages. Any thoughts on this subject? I've never heard of this before. Thanks, Jesse

                              Intermediate & Advanced SEO | | Waismann
                              0
                            • Milian

                              Robots.txt, does it need preceding directory structure?

                              Do you need the entire preceding path in robots.txt for it to match? e.g: I know if i add Disallow: /fish to robots.txt it will block /fish
                              /fish.html
                              /fish/salmon.html
                              /fishheads
                              /fishheads/yummy.html
                              /fish.php?id=anything But would it block?: en/fish
                              en/fish.html
                              en/fish/salmon.html
                              en/fishheads
                              en/fishheads/yummy.html
                              **en/fish.php?id=anything (taken from Robots.txt Specifications)** I'm hoping it actually wont match, that way writing this particular robots.txt will be much easier! As basically I'm wanting to block many URL that have BTS- in such as: http://www.example.com/BTS-something
                              http://www.example.com/BTS-somethingelse
                              http://www.example.com/BTS-thingybob But have other pages that I do not want blocked, in subfolders that also have BTS- in, such as: http://www.example.com/somesubfolder/BTS-thingy
                              http://www.example.com/anothersubfolder/BTS-otherthingy Thanks for listening

                              Intermediate & Advanced SEO | | Milian
                              0
                            • Bio-RadAbs

                              Can you redirect specific sub domain URLs?

                              ello! We host our PDFs, Images, CSS all in a sub domain. For the question, let's call this sub.cyto.com. I've noticed a particular PDF doing really well, infact it has gathered valuable external links from high authoritative sites. To top it off, it gets good visits. I've been going back and forth with our developers to move this PDF to a subfolder structure.
                              For example: www.cyto.com/document/xxxx.pdf In my perspective, if I move this and set up a permanent redirect, then all the external links the PDF gathered, link juice and future visits will be attributed to the main website. Since the PDF is existing in the subdomain, I can't even track direct visits nor get the link juice. It appears in top position of Google as well. My developer says it is better to keep images, pdf, css in the subdomain. I see his point and an idea I have is to: convert the pdf to a webpage. Set up a 301 redirect from the existing subdomain to this webpage Upload the pdf with a new name and link to it from the webpage, so users can download if they choose to. This should give me the existing rank juice. However, my question is whether you can set up a 301 redirect for just a single subdomain URL to a folder structure URL? sub.cyto.com/xxx.pdf to www.cyto.com/document/xxxx.pdf?

                              Intermediate & Advanced SEO | | Bio-RadAbs
                              0
                            • RikkiD22

                              Recovering from robots.txt error

                              Hello, A client of mine is going through a bit of a crisis. A developer (at their end) added Disallow: / to the robots.txt file. Luckily the SEOMoz crawl ran a couple of days after this happened and alerted me to the error. The robots.txt file was quickly updated but the client has found the vast majority of their rankings have gone. It took a further 5 days for GWMT to file that the robots.txt file had been updated and since then we have "Fetched as Google" and "Submitted URL and linked pages" in GWMT. In GWMT it is still showing that that vast majority of pages are blocked in the "Blocked URLs" section, although the robots.txt file below it is now ok. I guess what I want to ask is: What else is there that we can do to recover these rankings quickly? What time scales can we expect for recovery? More importantly has anyone had any experience with this sort of situation and is full recovery normal? Thanks in advance!

                              Intermediate & Advanced SEO | | RikkiD22
                              0
                            • AndrewY

                              Blocking Dynamic URLs with Robots.txt

                              Background: My e-commerce site uses a lot of layered navigation and sorting links.  While this is great for users, it ends up in a lot of URL variations of the same page being crawled by Google.  For example, a standard category page: www.mysite.com/widgets.html ...which uses a "Price" layered navigation sidebar to filter products based on price also produces the following URLs which link to the same page: http://www.mysite.com/widgets.html?price=1%2C250 http://www.mysite.com/widgets.html?price=2%2C250 http://www.mysite.com/widgets.html?price=3%2C250 As there are literally thousands of these URL variations being indexed, so I'd like to use Robots.txt to disallow these variations. Question: Is this a wise thing to do?  Or does Google take into account layered navigation links by default, and I don't need to worry. To implement, I was going to do the following in Robots.txt: User-agent: * Disallow: /*? Disallow: /*= ....which would prevent any dynamic URL with a '?" or '=' from being indexed.  Is there a better way to do this, or is this a good solution? Thank you!

                              Intermediate & Advanced SEO | | AndrewY
                              1

                            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.