How to disallow multiple folder in robots.txt - robots.txt

I want to disallow robots from crawling any folder/subfolder.
I want to disallow the ff:
http://example.com/staging/
http://example.com/test/
And this is the code inside my robots.txt
User-agent: *
Disallow: /staging/
Disallow: /test/
Is this right? and will it work?

Yes, it is right !
You have to add the command Disallow line by line to each path.
Like this:
User-agent: *
Disallow: /cgi-bin/
Disallow: /img/
Disallow: /docs/
A good trick is to use some Robot.txt Generator.
Another tip is test your Robot.txt using this Google Tool

Related

Write the correct robots txt file

I have a webshop on my test domain, no one knows it. I always store the search-es on the site into a search sql table, and there are always search-es with same words. Maybe a robot?
How can I fix this? What should I write into the robots.txt? What folders or links should I disable in the file?
My robots txt looks like:
User-agent: *
Disallow: /cms
Sitemap: http://www.my-domain.hu/sitemap.xml
Host: www.my-domain.hu
Sorry for bad english, I hope you understand what I write. :)
Update:
And what about this robotx file? Is it correct? What is MJ12bot?
User-agent: *
Disallow: /admin/
Disallow: /index.php?route=checkout*
Disallow: /cache/*/block/
Disallow: /custom/*/cache/block/
Disallow: /cib.php
Disallow: /cib_facebook.php
Disallow: /index.php?route=product/relatedproducts/
Disallow: /index.php?route=product/similar_products/
Disallow: /index.php?route=module/upsale/
Disallow: /.well-known/
Allow: /
Sitemap: http://mydomain.hu/sitemap.xml
User-Agent: MJ12bot
Disallow: /
To exclude all robots from accessing anything under the root
User-agent: *
Disallow: /
To allow all crawlers complete access
User-agent: *
Disallow:
Alternatively, you can skip creating a robots.txt file, or create one with empty content.
To exclude a single robot
User-agent: Googlebot
Disallow: /
This will disallow Google’s crawler from the entire website.
To allow just Google crawler
User-agent: Google
Disallow:
User-agent: *
Disallow: /
Is the basic idea. Does that work for you?
Source: https://www.wst.space/allow-disallow-robots-txt/

Disallow pages that ends with number only in robots.txt

Is it possible to tell Google not to crawl these pages
/blog/page/10
/blog/page/20
…
/blog/page/100
These are basically Ajax calls that bring blog posts data.
I created this in robots.txt:
User-agent: *
Disallow: /blog/page/*
But now I have to another page that I want allow which is
/blog/page/start
Is there a way that I tell robots that only pages that end with a number
e.g
User-agent: *
Disallow: /blog/page/(:num)
I also got an error bellow when I tried to validate the robots.txt file:
Following the original robots.txt specification, this would work (for all conforming bots, including Google’s):
User-agent: *
Disallow: /blog/pages/0
Disallow: /blog/pages/1
Disallow: /blog/pages/2
Disallow: /blog/pages/3
Disallow: /blog/pages/4
Disallow: /blog/pages/5
Disallow: /blog/pages/6
Disallow: /blog/pages/7
Disallow: /blog/pages/8
Disallow: /blog/pages/9
This blocks all URLs whose path begins with /blog/pages/ followed by any number (/blog/pages/9129831823, /blog/pages/9.html, /blog/pages/5/10/foo etc.).
So you should not append the * character (it’s not a wildcard in the original robots.txt specification, and not even needed in your case for bots that interpret it as wildcard).
Google supports some features for robots.txt which are not part of the original robots.txt specification, and therefore are not supported by (all) other bots, e.g., the Allow field. But as the above robots.txt would work, there is no need for using it.

Will a robots.txt file with "disallow / " stop all crawling of my website?

I know the following will stop all bots from crawling my site
User-agent: *
Disallow: /
But what about something like this:
User-agent: *
Crawl-delay: 10
# Directories
Disallow: /includes/
Disallow: /misc/
Disallow: /modules/
Disallow: /profiles/
Disallow: /scripts/
Disallow: /themes/
# Files
Disallow: /CHANGELOG.txt
Disallow: /cron.php
Disallow: /INSTALL.mysql.txt
Disallow: /INSTALL.pgsql.txt
Disallow: /INSTALL.sqlite.txt
Disallow: /install.php
Disallow: /INSTALL.txt
Disallow: /LICENSE.txt
Disallow: /MAINTAINERS.txt
Disallow: /update.php
Disallow: /UPGRADE.txt
Disallow: /xmlrpc.php
# Paths (clean URLs)
Disallow: /admin/
Disallow: /comment/reply/
Disallow: /filter/tips/
Disallow: /node/add/
Disallow: /search/
Disallow: /user/register/
Disallow: /user/password/
Disallow: /user/login/
Disallow: /user/logout/
# Paths (no clean URLs)
Disallow: /?q=admin/
Disallow: /?q=comment/reply/
Disallow: /?q=filter/tips/
Disallow: /?q=node/add/
Disallow: /?q=search/
Disallow: /?q=user/password/
Disallow: /?q=user/register/
Disallow: /?q=user/login/
Disallow: /?q=user/logout/
Disallow: /
I didn't want to comment out the entire file and logic told me that having the final Disallow: / line should override all the previous rules, but we got a report from the client that a form was submitted from the site this robots.txt file belongs to, leading us to believe it was indexed. Is there something I'm missing here?
Thanks ya'll!
As mentioned in the comments, the robots.txt file is no more than a request.
Polite web-crawlers will honor it, and potentially evil ones could ignore it or use it as a treasure map.
What you propose will work (to the extent that robots.txt work).
Here are the "rules":
It needs to be readable by your webserver (duh, huh?)
It needs to be at the root level of your webserver (e.g.
(http://www.example.com/robots.txt).
If you have multiple websites, each one needs a /robots.txt url (they
can share the actual file, if appropriate). Note that
http://www.example.com and https://www.example.com are two
different websites for these purposes as are http://www.example.com
and http://example.com, even if they deliver the same content.
The first match found applies (this is mostly important if you are
using the non-standard, (but widely implemented) Allow extension).
You can find some additional information here: https://en.wikipedia.org/wiki/Robots_exclusion_standard

robots.txt to disallow all pages except one? Do they override and cascade?

I want one page of my site to be crawled and no others.
Also, if it's any different than the answer above, I would also like to know the syntax for disallowing everything but the root (index) of the website is.
# robots.txt for http://example.com/
User-agent: *
Disallow: /style-guide
Disallow: /splash
Disallow: /etc
Disallow: /etc
Disallow: /etc
Disallow: /etc
Disallow: /etc
Or can I do like this?
# robots.txt for http://example.com/
User-agent: *
Disallow: /
Allow: /under-construction
Also I should mention that this is a WordPress install, so "under-construction," for example, is set to the front page. So in that case it acts as the index.
I think what I need is to have http://example.com craweld, but no other pages.
# robots.txt for http://example.com/
User-agent: *
Disallow: /*
Would this mean disallow anything after the root?
The easiest way to allow access to just one page would be:
User-agent: *
Allow: /under-construction
Disallow: /
The original robots.txt specification says that crawlers should read robots.txt from top to bottom, and use the first matching rule. If you put the Disallow first, then many bots will see it as saying they can't crawl anything. By putting the Allow first, those that apply the rules from top to bottom will see that they can access that page.
The expression rules are simple: the expression Disallow: / says "disallow anything that starts with a slash." So that means everything on the site.
Your Disallow: /* means the same thing to Googlebot and Bingbot, but bots that don't support wildcards could see the /* and think that you meant a literal *. So they could assume that it was okay to crawl /*foo/bar.html.
If you just want to crawl http://example.com, but nothing else, you might try:
Allow: /$
Disallow: /
The $ means "end of string," just like in regular expressions. Again, that'll work for Google and Bing, but won't work for other crawlers if they don't support wildcards.
If you log into Google Webmaster Tools, from the left panel go to crawling, then go to Fetch as Google. Here you can test how Google will crawl each page.
In the case of blocking everything but the homepage:
User-agent: *
Allow: /$
Disallow: /
will work.
you can use this below both will work
User-agent: *
Allow: /$
Disallow: /
or
User-agent: *
Allow: /index.php
Disallow: /
the Allow must be before the Disallow because the file is read from top to bottom
Disallow: / says "disallow anything that starts with a slash." So that means everything on the site.
The $ means "end of string," like in regular expressions. so the result of Allow : /$ is your homepage /index
http://en.wikipedia.org/wiki/Robots.txt#Allow_directive
The order is only important to robots that follow the standard; in the case of the Google or Bing bots, the order is not important.

My robots.txt is User-agent: * Disallow: /feeds/ Disallow: /*/_/ what its means?

I have a Google site, and today I found google generated a new robots.txt file:
User-agent: *
Disallow: /feeds/
Disallow: /*/_/
What does it mean? Your kind reply is appreciated.
Here is the breakdown:
User-agent: * -- Apply to all robots
Disallow: /feeds/ -- Do not crawl the /feeds/ directory
Disallow: /*/_/ -- Do not crawl any subdirectory that is named _
For more information, see www.robotstxt.org.
The User-Agent header is how browsers and robots identify themselves.
The Disallow lines define the rules the robots are supposed to follow - in this case what they shouldn't crawl.