Robots.txt detailed introduction

Robots.txt detailed introduction
Basic introduction to robots.txt
Robots.txt is a plain text file in which website administrators can declare parts of the website that they do not want to be accessed by robots, or specify that search engines only index specified content.
When a search robot (sometimes called a search spider) visits a site, it will first check whether there is a robots.txt in the root directory of the site. If it exists, the search robot will determine the scope of access according to the content of the file; if the file does not exist, the search robot will crawl along the link.
In addition, robots.txt must be placed in the root directory of a site, and the file name must be all lowercase.
Robots.txt writing syntax <br />First, let’s look at a robots.txt example: http://www.csswebs.org/robots.txt
Visit the above specific address, we can see the specific content of robots.txt as follows:
# Robots.txt file from http://www.csswebs.org
# All robots will spider the domain
User-agent: *
Disallow:
The above text means that all search robots are allowed to access all files under the www.csswebs.org site.
Specific syntax analysis: the text after # is explanatory information; User-agent: is followed by the name of the search robot. If it is followed by *, it refers to all search robots; Disallow: is followed by the file directory that is not allowed to access.
Below, I will list some specific uses of robots.txt:
Allow all robots to access
User-agent: *
Disallow:
Or you can create an empty file "/robots.txt" file
Block all search engines from accessing any part of the site
User-agent: *
Disallow: /
Block all search engines from accessing several sections of the site (directories 01, 02, 03 in the example below)

User-agent: *
Disallow: /01/
Disallow: /02/
Disallow: /03/
Block access to a search engine (BadBot in the example below)
User-agent: BadBot
Disallow: /
Only allow access from a certain search engine (Crawler in the example below)
User-agent: Crawler
Disallow:
User-agent: *
Disallow: /
In addition, I think it is necessary to expand on this and introduce robots meta:
The Robots META tag is mainly targeted at specific pages. Like other META tags (such as the language used, page description, keywords, etc.), the Robots META tag is also placed in the <head> </head> of the page, specifically used to tell search engine ROBOTS how to crawl the content of the page.
How to write the Robots META tag:
There is no case distinction in the Robots META tag. name="Robots" means all search engines, and can be written as name="BaiduSpider" for a specific search engine. The content part has four command options: index, noindex, follow, and nofollow. The commands are separated by ",".
The INDEX directive tells the search robot to crawl the page;
The FOLLOW instruction indicates that the search robot can continue crawling along the links on the page;
The default values ​​for the Robots Meta tag are INDEX and FOLLOW, except for inktomi, for which the default value is INDEX, NOFOLLOW.
Thus, there are four combinations:
<META NAME=”ROBOTS” CONTENT=”INDEX,FOLLOW”>
<META NAME="ROBOTS" CONTENT="NOINDEX,FOLLOW">
<META NAME=”ROBOTS” CONTENT=”INDEX,NOFOLLOW”>
<META NAME="ROBOTS" CONTENT="NOINDEX,NOFOLLOW">
Among them, <META NAME=”ROBOTS” CONTENT=”INDEX,FOLLOW”> can be written as <META NAME=”ROBOTS” CONTENT=”ALL”>;
<META NAME="ROBOTS" CONTENT="NOINDEX,NOFOLLOW"> can be written as <META NAME="ROBOTS" CONTENT="NONE">
At present, it seems that the vast majority of search engine robots abide by the rules of robots.txt. As for the Robots META tag, there is not much support at present, but it is gradually increasing. For example, the famous search engine GOOGLE fully supports it, and GOOGLE has also added a command "archive" that can limit whether GOOGLE retains web page snapshots. For example:
<META NAME=”googlebot” CONTENT=”index,follow,noarchive”>

<<:  How to optimize MySQL indexes

>>:  JavaScript to implement mobile signature function

Recommend

HTML Tutorial: DOCTYPE Abbreviation

When writing HTML code, the first line should be ...

An article to help you understand jQuery animation

Table of contents 1. Control the display and hidi...

js implementation of verification code case

This article example shares the specific code of ...

JavaScript imitates Jingdong magnifying glass special effects

This article shares the specific code of JavaScri...

Tutorial on using prepare, execute and deallocate statements in MySQL

Preface MySQL officially refers to prepare, execu...

Analysis of the principle of using PDO to prevent SQL injection

Preface This article uses pdo's preprocessing...

Interpretation of the module for load balancing using nginx

Table of contents Two modules for using nginx for...

How to operate Docker and images

Find mirror We can search for images from the Doc...

Vue implements top left and right sliding navigation

Navigation and other things are often used in dai...

Detailed Example of MySQL curdate() Function

MySQL CURDATE Function Introduction If used in a ...

SQL query for users who have logged in for at least n consecutive days

Take 3 consecutive days as an example, using the ...

Div adaptive height automatically fills the remaining height

Scenario 1: Html: <div class="outer"...

Complete step record of vue encapsulation TabBar component

Table of contents Implementation ideas: Step 1: C...

Detailed code for adding electron to the vue project

1. Add in package.json "main": "el...