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

                            • Magne_Vidnes

                              SEO implications of moving fra a sub-folder to a root domain

                              I am considering a restructure of my site, and was hoping for some input on SEO implications which I am having some issues getting clarity in. (I will be using sample domains/urls because of language reasons, not an english site), Thinking about moving a site (all content) from example.com/parenting -> parenting.com. This is to have a site fully devoted to this theme, and more easily monitor and improve SEO performance on this content alone. Today all stats on external links, DA etc is related to the root domain, and not just this sub-department. Plus it would be a better brand-experience of the content and site. Other info/issues: -The domain parenting.com (used as example) is currently redirected to example.com/parenting. So I would have to reverse that redirect, and would also redirect all articles to the new site. The current domain example.com has a high DA (67), but the new domain parenting.com has a much lower DA  (24). Question: Would the parenting.com domain improve it's DA when not redirected and the sub-folder on the high-DA domain is redirected here instead? Would it severly hurt SEO traffic to make this change, and if so is there a strategy to make the move with as little loss in traffic as possible? How much value is in having a stand-alone domain, which also is one of the most important keywords for this theme? My doubt comes mostly from moving from a domain with high DA to a domain with much lower DA, and I am not sure about how removing the redirect would change that, or if placing a new redirect from the subfolder on the current site would help improve it. Would some DA flow over with a 301 redirect? Thanks for any advice or hints to other documentation that might be of interest for this scenario 🙂

                              Intermediate & Advanced SEO | | Magne_Vidnes
                              0
                            • Taiger

                              The correct hreflang for the GB

                              Hi does anyone know the correct hreflang for the UK Google webmaster error: International Targeting | Language > 'en-GB' - no return tags (sitemaps)Sitemap provided URLs and alternate URLs in 'en-GB' that do not have return tags.Thanks you all

                              Intermediate & Advanced SEO | | Taiger
                              0
                            • GSO

                              Should I be using meta robots tags on thank you pages with little content?

                              I'm working on a website with hundreds of thank you pages, does it make sense to no follow, no index these pages since there's little content on them? I'm thinking this should save me some crawl budget overall but is there any risk in cutting out the internal links found on the thank you pages? (These are only standard site-wide footer and navigation links.) Thanks!

                              Intermediate & Advanced SEO | | GSO
                              0
                            • Modbargains

                              Dilemma about "images" folder in robots.txt

                              Hi, Hope you're doing well. I am sure, you guys must be aware that Google has updated their webmaster technical guidelines saying that users should allow access to their css files and java-scripts file if it's possible. Used to be that Google would render the web pages only text based. Now it claims that it can read the css and java-scripts. According to their own terms, not allowing access to the css files can result in sub-optimal rankings. "Disallowing crawling of Javascript or CSS files in your site’s robots.txt directly harms how well our algorithms render and index your content and can result in suboptimal rankings."http://googlewebmastercentral.blogspot.com/2014/10/updating-our-technical-webmaster.htmlWe have allowed access to our CSS files. and Google bot, is seeing our webapges more like a normal user would do. (tested it in GWT)Anyhow, this is my dilemma. I am sure lot of other users might be facing the same situation. Like any other e commerce companies/websites.. we have lot of images. Used to be that our css files were inside our images folder, so I have allowed access to that. Here's the robots.txt --> http://www.modbargains.com/robots.txtRight now we are blocking images folder, as it is very huge, very heavy, and some of the images are very high res. The reason we are blocking that is because we feel that Google bot might spend almost all of its time trying to crawl that "images" folder only, that it might not have enough time to crawl other important pages. Not to mention, a very heavy server load on Google's and ours. we do have good high quality original pictures. We feel that we are losing potential rankings since we are blocking images. I was thinking to allow ONLY google-image bot, access to it. But I still feel that google might spend lot of time doing that. **I was wondering if Google makes a decision saying, hey let me spend 10 minutes for google image bot, and let me spend 20 minutes for google-mobile bot etc.. or something like that.. , or does it have separate "time spending" allocations for all of it's bot types. I want to unblock the images folder, for now only the google image bot, but at the same time, I fear that it might drastically hamper indexing of our important pages, as I mentioned before, because of having tons & tons of images, and Google spending enough time already just to crawl that folder.**Any advice? recommendations? suggestions? technical guidance? Plan of action? Pretty sure I answered my own question, but I need a confirmation from an Expert, if I am right, saying that allow only Google image access to my images folder. Sincerely,Shaleen Shah

                              Intermediate & Advanced SEO | | Modbargains
                              1
                            • seo.owl

                              How to handle a blog subdomain on the main sitemap and robots file?

                              Hi, I have some confusion about how our blog subdomain is handled in our sitemap.  We have our main website, example.com, and our blog, blog.example.com. Should we list the blog subdomain URL in our main sitemap?  In other words, is listing a subdomain allowed in the root sitemap? What does the final structure look like in terms of the sitemap and robots file?  Specifically: **example.com/sitemap.xml ** would I include a link to our blog subdomain (blog.example.com)? example.com/robots.xml would I include a link to BOTH our main sitemap and blog sitemap? blog.example.com/sitemap.xml would I include a link to our main website URL (even though it's not a subdomain)? blog.example.com/robots.xml does a subdomain need its own robots file? I'm a technical SEO and understand the mechanics of much of on-page SEO.... but for some reason I never found an answer to this specific question and I am wondering how the pros do it.  I appreciate your help with this.

                              Intermediate & Advanced SEO | | seo.owl
                              0
                            • damienthivolle

                              Subdomains vs directories on existing website with good search traffic

                              Hello everyone, I operate a website called Icy Veins (www.icy-veins.com), which gives gaming advice for World of Warcraft and Hearthstone, two titles from Blizzard Entertainment. Up until recently, we had articles for both games on the main subdomain (www.icy-veins.com), without a directory structure. The articles for World of Warcraft ended in -wow and those for Hearthstone ended in -hearthstone and that was it. We are planning to cover more games from Blizzard entertainment soon, so we hired a SEO consultant to figure out whether we should use directories (www.icy-veins.com/wow/, www.icy-veins.com/hearthstone/, etc.) or subdomains (www.icy-veins.com, wow.icy-veins.com, hearthstone.icy-veins.com). For a number of reason, the consultant was adamant that subdomains was the way to go. So, I implemented subdomains and I have 301-redirects from all the old URLs to the new ones, and after 2 weeks, the amount of search traffic we get has been slowly decreasing, as the new URLs were getting index. Now, we are getting about 20%-25% less search traffic. For example, the week before the subdomains went live we received 900,000 visits from search engines (11-17 May). This week, we only received 700,000 visits. All our new URLs are indexed, but they rank slightly lower than the old URLs used to, so I was wondering if this was something that was to be expected and that will improve in time or if I should just go for subdomains. Thank you in advance.

                              Intermediate & Advanced SEO | | damienthivolle
                              0
                            • geniusenergyltd

                              Citation/Business Directory Question...

                              A company I work for has two numbers... one for the std call centre and one for tracking SEO. Now, if local citation/business directory listings have the same address but different numbers, will this affect local/other SEO results? Any help is greatly appreciated! 🙂

                              Intermediate & Advanced SEO | | geniusenergyltd
                              0
                            • IHSwebsite

                              Robots.txt: Can you put a /* wildcard in the middle of a URL?

                              We have noticed that Google is indexing the language/country directory versions of directories we have disallowed in our robots.txt. For example: Disallow: /images/ is blocked just fine However, once you add our /en/uk/ directory in front of it, there are dozens of pages indexed. The question is: Can I put a wildcard in the middle of the string, ex. /en/*/images/, or do I need to list out every single country for every language in the robots file. Anyone know of any workarounds?

                              Intermediate & Advanced SEO | | IHSwebsite
                              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.