How does the browser generate a URL?
Click the link on the page and the browser will perform different processing based on the relative URL path in the source code:
(1) There is a protocol name, but there is no Domain Name Information
For a URL in this form, its Protocol, path, query string, and fragment ID are subject to its own, but the part of the domain name information is subject to the page address that references it.
(2) No protocol name, But Domain Name Information
The protocol name is determined by the original launch page, and all subsequent URL information is taken from this relative URL to form a complete URL.
(3) No protocol name, no domain name information, but path
If the base tag is explicitly provided on the webpage, the obtained URL is base URL + path.
If no base tag is provided, there are two results:
A) if the relative URL starts with a slash (root directory), the URL Information of the current page is ignored and the relative path is directly placed behind the Domain Name of the current page.
B) if the start of the relative URL is not a slash, the last/suffix content of the current page URL will be removed, and the remaining content will be returned as the base URL, and the relative path will be spliced after it.
(4) No protocol name, domain name information, no path, but query string
The Protocol, domain name, and path information are all copied from the original referenced URL, and the query string and fragment ID are from the relative URL.
(5) Only fragment
Only fragment is replaced. All other information is copied from the original referenced URL.
<Base> tag
The browser extracts the corresponding part from the UR of the current page to fill in the blank space in the relative URL. You can use the <base> label to change the value. The browser will no longer use the URL of the current document, but will use the specified basic URL to parse all relative URLs. These include the URLs in the <a>, , <link>, and <form> labels.
The browser also adjusts the URL of the current page and generates a new request URL in the address bar.