关于html:URL的字符限制是什么

What is the character limit on URL

本问题已经有最佳答案,请猛点这里访问。

URL的字符限制是什么,特别是如果URL是从表单的get方法形成的。


根据微软的说法,现在是2048年。因为他们发明了互联网(还有光明、黑暗和Linux),所以他们是对的。-……或…因为ie强制这个较低的值,所以它是最小的公分母。

http://support.microsoft.com/kb/208427

在firefox下,我看到网络上的人在报告0xffff的网址:http://forums.mozillazine.org/viewtopic.php?F=38&t=155648&start=0&st=0&sk=t&sd=A

下面是另一篇讨论这个问题的文章:http://hiox.org/index.php?ID=425

编辑:在我写下这个答案将近5年后,这是非常可悲的-它仍然是真的。如果可以的话,看看这个答案的历史。

edit2:我在stackoverflow上找到了一个更好的答案——在不同的浏览器中,URL的最大长度是多少?

edit3:9年后-explorer被弃用,取而代之的是edge,edge很快将使用blink重新设计(使其非常接近chrome)。我想知道这个答案有多重要。


没有发布的最大值,但是有效的限制是大约2000个字符,因为这是Internet Explorer(版本4及更高版本)所支持的。请参阅http://www.boutell.com/newfaq/misc/urllength.html


解释

根据RFC2616(超文本传输协议-HTTP/1.1-第3.2.1节),没有针对HTTP Get请求的最大URL大小制定经验规则。

限制由不同的浏览器和各自的服务器实施。在任何HTTP请求中传递URL中传递的查询字符串时,必须集体考虑这些限制。

如果URL大小超过了各自浏览器施加的URL大小限制,则不会将请求传递给服务器,调试和处理此情况需要不必要的努力。

最大URL大小…浏览器

  • Internet Explorer

    2048 B

    Microsoft Internet Explorer has a maximum uniform resource locator (URL) length of 2,083 characters. Internet Explorer also has a maximum path length of 2,048 characters. This limit applies to both POST request and GET request URLs.If you are using the GET method, you are limited to a maximum of 2,048 characters, minus the number of characters in the actual path.

    < /块引用>

  • Mozilla Firefox

    100 KB

    The address bar doesn’t shows any characters beyond 65,536 characters. But the URL size can be more than that, though you cannot view it in the address bar. This holds for FireFox 1.5 up until the current FireFox version

    < /块引用>

  • 歌剧

    200 KB

    The URL is completely visible in the address bar even at such a big range

    < /块引用>

  • 铬,狩猎

    100 KB

    Both browsers are webkit based and seems to have almost same limit as firefox

    < /块引用>

  • 服务器

  • 阿帕奇

    128 KB

    The size is changed using the LimitRequestLine setting of the server

    < /块引用>

  • 伊斯

    16 KB

    Default value is 16 KB and maximum limit is 16 MB

    < /块引用>

  • 莲花笔记

    4 KB

  • 更多信息

    根本不建议使用非常长的URL。要使基于Web的应用程序能够跨浏览器兼容,不能使用Get方法传递包含2000个以上字符的非常长的字符串。

    如果您正面临一个需要使用URL来包含大量字符的情况,那么请考虑一下。


    不同的浏览器有不同的限制。但是对于URL的get方法,通常限制在2000个字符左右。您可以使用一个代理页面来执行post方法(如果您的API支持该方法),并且该代理页面的长度不能超过5000个字符。我们目前正在调查使用谷歌地图API的代理页面,因为我们已经崩溃到了2000个字符的限制。


    更新的IE:2048个字符有些平台只支持255个。