1. 概述
In this tutorial, we’ll discuss the maximum length of a URL in different browsers. We also present the basic concept of URL, web browser, and web server.
2. URL 介绍
The complete form of a URL is Uniform Resource Locator. A URL is also known as a web address. It consists of a unique string and works as a reference to the web resources on a computer network. More specifically, a URL provides the location and retrieval mechanism of web resources such as an image, audio, video, text, or HTML file. Additionally, a URL is one type of Uniform Resource Identifier.
In 1994, Tim Berners-Lee defined URL in RFC 1738. We can easily find the URL of a website at the top address bar of a web browser. We use them in referencing web pages. Additionally, several applications, such as accessing a database, transferring a file utilize them.
In general, a URL consists of three parts: protocol, hostname, and file name. Let’s look at an example:
Here “HTTPS” denotes the protocol: Hypertext Transfer Protocol Secure (HTTPS). Moreover, “www.baeldung.com” represents the hostname of the website. Finally, “about” depict the file name of the website.
3. Web 浏览器
We generally use a web browser to fetch web resources from the World Wide Web (WWW) and present the contents on the user’s device via an interface. It’s a software application implemented and developed with programming languages.
A web browser is different from a search engine. A search engine redirects and gives the links to the other websites. In contrast, a web browser identifies and connects to a particular website’s web server and displays the contents of a web page to the user’s device.
Initially, the user provides an input URL in the web address bar of a web browser. Next, the web browser sends a request to a web server through the World Wide Web. The web server is connected with a database that stores the web resources of the website. Therefore, it responds to the browser’s request with the required web content. Finally, the browser shows the webpage for the input URL:
We generally use either HTTP or HTTPS in order to fetch web resources from the webserver. However, HTTPS is more secure than HTTP. Communication through HTTPS is encrypted and enhances security.
Some webpage may contain hyperlinks that redirect the user from a website to another website or resources. If the users click on such links, the process of retrieving the data starts again.
Popular web browsers include Google Chrome, Mozilla Firefox, Internet Explorer, Safari, Opera, Apache.
4. Web Server
A web server is a combination of software and hardware. It accesses the web resources stored in a dataset and forwards them to the user’s browser via the World Wide Web. Web servers generally use either HTTP or HTTPS. However, web servers also work with SMTP for sending emails and FTP for sending files.
There’re two types of web servers: static and dynamic. A static web server only contains HTTP and a host device. It forwards web resources without any control over them. On the other hand, dynamic web servers contain HTTP, a host device, an application server, and a database.
A dynamic web server can update and control the flow of web resources. Additionally, it can generate and forward the web resources at the user’s request.
Some examples of popular web servers are Apache HTTP Server, Microsoft Internet Information Services, Lighttpd, Sun Java System Web Server, Nginx.
5. 不同浏览器支持的 URL 的最大长度
URL的长度并不是固定的,不同浏览器的标准会有所不同。一般来说,URL的最大长度可以达到 个字符。 因此,一个网站的过长URL被认为是WWW中排名的负面因素。
In general, a URL consisting of characters can be appropriately indexed. Additionally, a URL with fewer characters has a higher probability of achieving a good rank in the WWW.
Now let’s discuss the maximum length of a URL in different web browsers.
作为最流行的浏览器,谷歌 Chrome 限制 URL 最长为 2048 个字符。Hence, we can’t enter more than 2048 characters in the web address bar of the Google Chrome browser.
在火狐浏览器Firefox中,URL没有限制最大长度。但 超过65536个字符后,Firefox的地址栏不再显示URL。
IE浏览器 URL的最大长度可以达到 2083 个字符。
Safari 浏览器支持的 URL 最多可以有 80000 个字符。 如果提供的 URL 超过 80000 个字符,将会生成错误。
Opera 对 URL 长度没有限制。但 它的地址栏可以显示最多 190000 个字符。
最后,Apache支持的最大字符数为4000个。 超过4000个字符将会生成错误。
Let’s summarize the maximum length of a URL for the various browsers:
浏览器 | URL 长度 |
---|---|
Chrome | 最长 2048 |
Firefox | 超过65536不显示URL |
IE | 最长 2083 |
Safari | 最长 80000 |
Opera | 地址栏最多显示 190000 |
Apache | 支持最多 4000 个字符 |
6. 总结
In this tutorial, we have discussed the maximum length of a URL in different browsers. In order to give the readers a complete picture, we also presented the basic concept of URL, web browser, and web server.