What is the URL
URL is a Uniform Resource Locator,
Component of the URL
URL = Protocol + Domain name or IP address + port number [omitted by default] + path + query parameters + anchor point
For example: baike.baidu.com/search?word…
- Protocol: HTTPS
- Domain name: baike.baidu.com
- Port: The default port is 443
- Path: / ssearch
- Query string:? word=123&pn=0&rn=0&enc=utf8
- Anchor: # 1
agreement
HTTP uses port 80 by default, and HTTPS uses port 443 by default
The domain name
A domain name is an alternate name for IP.
- A domain name can have multiple IP addresses (this is called load balancing to prevent one machine from becoming overwhelmed)
- One IP can have different domain names (this is called shared hosting, for poor developers)
IP related
- An IP address can locate a device
- IP is divided into external IP (router at home) and internal IP (mobile phone and computer).
- Devices on the Intranet can access each other, but cannot directly access the Internet
- An Intranet device needs to access the Internet through a router
- Devices on the extranet can access each other, but cannot directly access the Intranet
- The extranet also needs to access the Intranet through a router
ping baidu.com
Can you check what domain name corresponds to what IP, and the website latency
IP addresses are classified into external IP addresses and internal IP addresses
Special IP address
- 127.0.0.1 indicates itself
- Localhost specifies itself by host
- 0.0.0.0 does not indicate any device
Domain classification
- The first level is the top-level domain, which includes generic top-level domains such as.com,.net, and.org. And country and region top-level domains, such as.us,.cn, and.tk
- Baidu.com is a secondary domain name
- www.baidu.com is a level 3 domain name
So www.baidu.com and Baidu.com are two domain names. IO is the domain name of github, and userid.github. IO is the domain name of each user
The port number
A server can provide many services, and each service has a different number. This number is the port.
- Port 80: HTTP service
- Port 443: HTTPS service
- 21 Port: FTP service
Port usage rules
- Ports 0-1023 are for system use. We generally use ports after 1024
- For example, http-server uses port 8080 by default
- If one port number is occupied, other ports must be used
- Different ports can be specified with the -p argument, for example, port 1023 can be specified
http-server -c-1 -p 1023
Copy the code
The path
How to request different pages on the same server? Paths are not necessarily suffixed developer.mozilla.org/zh-CN/docs/… Developer.mozilla.org/zh-CN/docs/…
Query parameters
Can I request the same page and get different content? Query parameters www.baidu.com/s?wd=hi www.baidu.com/s?wd=hello
The anchor
Same content, different location? Use the anchor point developer.mozilla.org/zh-CN/docs/… Developer.mozilla.org/zh-CN/docs/… Note that anchors do not support Chinese, they will be encoded in Chinese. # Reference books will become #%E5%8F%82%E8%80%83%E4%B9%A6 Anchors cannot be seen on the network because they are not transmitted to the server
DNS
DNS is the abbreviation of Domain Name System (DNS). It consists of a Domain Name server (DNS) and a Domain Name server (DNS). Domain names correspond to IP addresses through DNS
How to find the corresponding IP address by domain name
- Nslookup + Domain name such as nslookup baidu.com How many IP addresses can be found