Disallow URLs that contain a directory - robots.txt

I have URLs which appear like so:
www.website.com/user/1
www.website.com/user/2
www.website.com/user/3
As you can see, they all contain /user/ and then a number. How can I disallow URLs like this in my robots.txt? Thanks.

Add this to your robots.txt
Disallow: /user/

Related

How to exclude URLs from robots.txt file

I have a lot of URLs in English and Chinese containing documents (content). Both URLs content are same, so I want to disallow Chinese language URLs from robots.txt.
Below a snippet of my URLs:
https://www.example.com/zh/docs/UBX-18006379
https://www.example.com/zh/ubx-viewer/view/cB-2254-12(fw_obs421_rd_v5.3.2).bin
Am I right with following wildcard:
1- Disallow: /zh/docs/*
2- Disallow: /zh/ubx-viewer/*
Can anyone please help me? is above is right to use?
Thanks in advance
No, it is not correct. Robots does not support regular expressions.
According to https://www.robotstxt.org/robotstxt.html
Note also that globbing and regular expression are not supported in
either the User-agent or Disallow lines. The '' in the User-agent
field is a special value meaning "any robot". Specifically, you cannot
have lines like "User-agent: bot", "Disallow: /tmp/" or "Disallow:
*.gif".
But please, remember that robots.txt can be ignored by bots. So be aware that anyone can still access those directories if they are publicly available, and you shouldn't store sensitive information in it.
So in your case, if you want to exclude those directories:
User-agent: *
Disallow: /zh/docs/
Disallow: /zh/ubx-viewer/

"Disallow: /test/programmming" or "Disallow: /programming"?

I manage a site under WordPress. We had to change the site URL to example.com/test. So, I now have 2 properties in Search Console: one with the root domain (example.com). The other with the subdirectory (example.com/test).
Whenever I search site:example.com in Google, it returns all the indexable URLs which is example.com/test for the home page. The domain root example.com is therefore not indexable anymore.
In robots.txt, I like to disallow some URLs such as example.com/test/programming.
Should I disallow: /programming OR disallow: /test/programmming so that example.com/test/programming becomes blocked?
Disallow values always represent the beginning of the URL path.
For https://example.com/test/programming, the path is /test/programming.
So, Disallow: /test/programming would block URLs like these:
https://example.com/test/programming
https://example.com/test/programming/
https://example.com/test/programming.html
https://example.com/test/programming/foo/bar
And Disallow: /programming would block URLs like these:
https://example.com/programming
https://example.com/programming/
https://example.com/programming.html
https://example.com/programming/foo/bar

How do I disallow search robots from www.example.com and exsample.com

I would like to know if it is possible to block all robots from my site. I get some trouble because I redirect exsample.com to www.exsample.com. The robots.txt checker tools says I don't have a robots.txt file on exsample.com but have it on www.exsample.com.
Hope someone can help me out :)
just make a text file named robots.txt and in this file you write the following
User-agent: *
Disallow: /
and put it in your www folder or public_html folder
this would ask all the search engines to disallow all content of the website but not all the search engines would obbay to this protocol, but the most important search engines would read it and do as you asked
Robots.txt works per host.
So if you want to block URLs on http://www.example.com, the robots.txt must be accessible at http://www.example.com/robots.txt.
Note that the subdomain matters, so you can’t block URLs on http://example.com with a robots.txt only available on http://www.example.com/robots.txt.

Remove multiples urls of same type from google webmaster

I accidentally kept some urls of type www.example.com/abc/?id=1 in which value of id can vary from 1 to 200. I don't want these to appear in search so i am using remove url feature of google webmasters tools. How can i remove all these types of urls in one shot? i tried www.example.com/abc/?id=* but this doesn't worked!
just block them using robots.txt ie.
User-agent: *
Disallow: /junk.html
Disallow: /foo.html
Disallow: /bar.html

block google robots for URLS containing a certain word

my client has a load of pages which they dont want indexed by google - they are all called
http://example.com/page-xxx
so they are /page-123 or /page-2 or /page-25 etc
Is there a way to stop google indexing any page that starts with /page-xxx using robots.txt
would something ike this work?
Disallow: /page-*
Thanks
In the first place, a line that says Disallow: /post-* isn't going to do anything to prevent crawling of pages of the form "/page-xxx". Did you mean to put "page" in your Disallow line, rather than "post"?
Disallow says, in essence, "disallow urls that start with this text". So your example line will disallow any url that starts with "/post-". (That is, the file is in the root directory and its name starts with "post-".) The asterisk in this case is superfluous, as it's implied.
Your question is unclear as to where the pages are. If they're all in the root directory, then a simple Disallow: /page- will work. If they're scattered across directories in many different places, then things are a bit more difficult.
As #user728345 pointed out, the easiest way (from a robots.txt standpoint) to handle this is to gather all of the pages you don't want crawled into one directory, and disallow access to that. But I understand if you can't move all those pages.
For Googlebot specifically, and other bots that support the same wildcard semantics (there are a surprising number of them, including mine), the following should work:
Disallow: /*page-
That will match anything that contains "page-" anywhere. However, that will also block something like "/test/thispage-123.html". If you want to prevent that, then I think (I'm not sure, as I haven't tried it) that this will work:
Disallow: */page-
It looks like the * will work as a Google wild card, so your answer will keep Google from crawling, however wildcards are not supported by other spiders. You can search google for robot.txt wildcards for more info. I would see http://seogadget.co.uk/wildcards-in-robots-txt/ for more information.
Then I pulled this from Google's documentation:
Pattern matching
Googlebot (but not all search engines) respects some pattern matching.
To match a sequence of characters, use an asterisk (*). For instance, to block access to all >subdirectories that begin with private:
User-agent: Googlebot
Disallow: /private*/
To block access to all URLs that include a question mark (?) (more specifically, any URL that begins with your domain name, followed by any string, followed by a question mark, followed by any string):
User-agent: Googlebot
Disallow: /*?
To specify matching the end of a URL, use $. For instance, to block any URLs that end with .xls:
User-agent: Googlebot
Disallow: /*.xls$
You can use this pattern matching in combination with the Allow directive. For instance, if a ? indicates a session ID, you may want to exclude all URLs that contain them to ensure Googlebot doesn't crawl duplicate pages. But URLs that end with a ? may be the version of the page that you do want included. For this situation, you can set your robots.txt file as follows:
User-agent: *
Allow: /?$
Disallow: /?
The Disallow: / *? directive will block any URL that includes a ? (more specifically, it will block any URL that begins with your domain name, followed by any string, followed by a question mark, followed by any string).
The Allow: /*?$ directive will allow any URL that ends in a ? (more specifically, it will allow any URL that begins with your domain name, followed by a string, followed by a ?, with no characters after the ?).
Save your robots.txt file by downloading the file or copying the contents to a text file and saving as robots.txt. Save the file to the highest-level directory of your site. The robots.txt file must reside in the root of the domain and must be named "robots.txt". A robots.txt file located in a subdirectory isn't valid, as bots only check for this file in the root of the domain. For instance, http://www.example.com/robots.txt is a valid location, but http://www.example.com/mysite/robots.txt is not.
Note: From what I read this is a Google only approach. Officially there is no Wildcard allowed in robots.txt for disallow.
You could put all the pages that you don't want to get visited in a folder and then use disallow to tell bots not to visit pages in that folder.
Disallow: /private/
I don't know very much about robots.txt so I'm not sure how to use wildcards like that
Here, it says "you cannot use wildcard patterns or regular expressions in either User-agent or Disallow lines."
http://www.robotstxt.org/faq/robotstxt.html