The URL contains several sections
- agreement
- The domain name or IP
- The port number
- The path
- Query parameters
- The anchor
1. The agreement
Protocol. We generally use HTTP and HTTPS protocols. Protocols enable data to travel from source to destination over the network, and all participants in network communication must follow the same rules.
The difference between HTTP and HTTPS:
HTTP Hyper Text Transfer Protocol
HTTPS Hyper Text Transfer Protocol over SecureSocket Layer
The differences between HTTP and HTTPS are as follows: Different information transfer security, connection modes, ports, and certificate application modes.
First, the security of transmission information is different:
- HTTP is a hypertext transfer protocol, and information is transmitted in plaintext. If an attacker intercepts a packet transmitted between a browser and a server, the attacker can directly obtain the information in the packet to modify or delete the packet.
- HTTPS is a secure SSL encryption transmission protocol. Encrypts the communication between the browser and the server to ensure the security of data transmission.
2. Different connection modes.
- HTTP protocol: HTTP connections are simply stateless.
- HTTPS: a network protocol that uses SSL and HTTP to implement encrypted transmission and identity authentication.
Three, different ports
- HTTP: port 80.
- HTTPS: port 443.
Iv. Different application methods for certificates:
- HTTP: Free application
- HTTPS protocol: Requires the use of a CA certificate, generally need to pay a fee, few free.
2.1 IP
IP is the network protocol. What it does is:
- How do I locate a device
- How to encapsulate data packets for communication with other devices
2.2 the domain name
A domain name is another name for IP. Domain names are divided into:
- Top-level domains, such as com;
- Secondary domain names (commonly known as level 1 domain name), such as Baidu.com;
- Level 3 domain names (commonly known as level 2 domain names), such as www.baidu.com
How do you know the IP of a domain name? The easiest way to do that is to ping. For example, ping baidu.com in CMD will get the IP address of Baidu.com.
A domain name can correspond to different IP addresses. This is called load balancing, and it’s a server optimization technique in case the number of visitors becomes too large for the server to handle.
An IP address can also have different domain names. This is called shared hosting and is usually used by poorer developers.
2.2.1 DNS
DNS is used to connect domain names to IP addresses. When you charge money for the telecom services, telecom will send a DNS server address, when are you going to visit a web site, the browser will be the first to telecom DNS servers for this domain name corresponding IP, browser on 80/443 according to the corresponding IP port sends the request, the request is to you to access the content of the website page. You can see the entire Network access process in the Developer tools Network panel of your browser.
2.2.2 the curl command
You can also use the curl command to query the DNS server for its IP address. Using curl -v www.baidu.com, you can also see the whole process, and more clearly. Curl curl curl curl curl curl curl curl curl curl
- The URL is rewritten with the curl command
- Making a TCP Connection
- After success, send the HTTP request
- Server response
- The TCP connection is closed
- Really over
3. The port number
What is a port? A machine can provide many services. Each service has a number. This number is the port number. Commonly used, such as:
- HTTP – 80 port
- HTTPS – 443 port
- FTP – 21 port
Now there are a total of 65535 ports, which can basically meet the demand. You can check Wikipedia for port numbers for other services.
Rules for port numbers:
- 0-1023 is reserved for system use. You need to have administrator rights to use it, but it is not recommended to use it.
- Everything else is for ordinary users to use at any time. We generally use http-Server as a trial port 8080.
- Once a port is occupied, it cannot be used and can only be replaced with another port.
- Both IP and port are indispensable.
4. The path
What paths do: If you want to request different pages, you can use paths to do so. For example: developer.mozilla.org/zh-CN/docs/… / zh-cn /docs/Web/HTML is the path, indicating that you are requesting the HTML content of the Web content in the Chinese document.
Developer.mozilla.org/zh-CN/docs/… If you change the HTML to CSS, you’ll go to the content of the CSS.
Using paths allows you to request different pages.
5. Query parameters
Query parameters function: to achieve the same page, different content; For example, the search page is www.baidu.com/s?wd= protocol /s, and? Wd = protocol is the search parameter.
www.baidu.com/s?wd=IP Change the query parameters to present a different page.
6. The anchor
What anchors do: Implement different locations of the same content. For example, in the MDN CSS page content, want to see a tutorial or reference book:
Developer.mozilla.org/zh-CN/docs/… (%E6%95%99%E7%A8%8B) The tutorial following the # sign is the anchor point.
Developer.mozilla.org/zh-CN/docs/… (%E5%8F%82%E8%80%83%E4%B9%A6) Change the # to show the content in a different position.
Note:
- Anchors appear to have Chinese characters, but they do not support Chinese characters. If you copy the URL, the Chinese characters will be displayed as a string, as shown in parentheses in the above example.
- Anchors are not visible in the Network panel because they are not transmitted to the server, and both # and anchor are blocked by the browser.
To summarize
URL: Uniform Resource Locator (URL). It consists of protocols, domain names or IP addresses, port numbers, paths, query parameters, and anchors.