The composition of the URL

URL: Full Uniform Resource Locator consists of six parts

For example: https://www.baidu.com/s?wd=hello&rsv-spt=1#5Copy the code
  • agreement

It is usually HTTP or a secure version of HTTP, called HTTPS

  • The domain name/IP

1. The domain name specifies two things: first, how to locate a device; How to encapsulate data packets to communicate with other devices?

2. The router has two IP addresses, an internal IP address and an external IP address. Devices on the Intranet can access each other, and devices on the Internet can access each other. However, routers are required to connect and access the Internet.

3. Several special IP addresses

  • 127.0.0.1 indicates itself
  • Localhost is specified as itself through hosts
  • 0.0.0.0 does not indicate any device

You can change any string to the corresponding IP address by setting hosts.

  • The port number

Ports are used to locate services provided by the device. A total of 65535 ports are sufficient. Ports 0 to 1023 are reserved for the system and can be used by administrators.

Common services correspond to the following ports: HTTP service-80; HTTPS service -443 port; FTP service-21 Port.

  • Paths request different interfaces
  • The query string requests different content from the same interface
  • Anchors request different locations of the same content

Mapping between domain names and IP addresses

4.1 Definition and Query

A domain name is another name for an IP address. A domain name can correspond to different IP addresses. This is called load balancing. An IP address can also correspond to a different domain name. This is called a shared host. You can use the command line to determine the IP address of the domain name.

ping baidu.com
ping qq.com
Copy the code

Domain names and IP addresses can be mapped using DNS (Domain name Service).

nslookup baidu.com
Copy the code

The command line query process includes:

1. The browser queries the DNS server provided by China Telecom/Unicom for the IP address of XXX.

2. Telecom/Unicom answers an IP.

3. The browser sends a request to the corresponding IP address (port 80/443).

4. Request content: View the home page of XXX.

4.2 classification

A domain name is made up of several parts (maybe just one part, maybe two parts, three parts…) It’s a simple structure that’s separated by dots.

1. Top-level domain Name A top-level domain name can tell users the type of services provided by the domain name. The most common top-level domains (.com,.org,.net)

2. The label just before the TLD is also called the second level domain name (SLD). Take, for example, Baidu.com

3, level 3 domain name for example: www.baidu.com is a sub-domain name of level 2 domain name. They are father and son.

Xxx.com and www.xxx.com may or may not be the same company.