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

Web design experience: Make the navigation system thin

<br />When discussing with my friends, I men...

Detailed deployment of docker+gitlab+gitlab-runner

environment Server: centos7 Client: window Deploy...

How to install binary MySQL on Linux and crack MySQL password

1. Make sure the system has the required libaio s...

JavaScript event loop case study

Event loop in js Because JavaScript is single-thr...

The difference between name and value in input tag

type is the control used for input and output in t...

The difference and usage of Ctrl+z, Ctrl+c and Ctrl+d in Linux commands

What does Ctrl+c, Ctrl+d, Ctrl+z mean in Linux? C...

Detailed explanation of MySQL phantom reads and how to eliminate them

Table of contents Transaction Isolation Level Wha...

Setting up VMware vSphere in VMware Workstation (Graphic Tutorial)

VMware vSphere is the industry's leading and ...

Docker container introduction

1. Overview 1.1 Basic concepts: Docker is an open...

Detailed explanation of the principle of Vue monitoring data

Table of contents 1. Introduction II. Monitoring ...

Quickly master how to get started with Vuex state management in Vue3.0

Vuex is a state management pattern developed spec...

Detailed steps for debugging VUE projects in IDEA

To debug js code, you need to write debugger in t...