HTTP RFC2616协议没有规定URL的最大长度,但规定服务器如果不能处理太长的URL,就得返回414状态码(Request-URI Too Long)。 HTTP RFC2616协议指出,某些旧的客户端或代理,可能无法处理超过255个字节的URI。 既然HTTP协议没有规定URL的最大长度,那么URL的最大长度与用户的浏览器有关,同时和服务器能够处理的最大长度URL有关。 站点地图协议(sitemap protocol),限制URL的长度是2048,如果你想让搜索引擎能够搜索到你,2048是最大极限了。 Google最大能抓取和索引2047个字节的URL,但是,用户点击的时候会返回414,经过测试,Google的SERP连接,最大不能超过1855个字符,超过这个数,用户点击则返回414。 IE8的URL的最大URL长度是2083个字节,其中路径部分(Path)最大长度是2048个字节。IE9也有类似限制,IE10也只接受2083个字节。虽然点击URL长度比这个长的连接依然可以工作,但地址栏只显示前2083个字节。 有网友测试了个浏览器和服务器支持的最大URL长度,附表如下:

IE

URL最大限制是2083个字节,Path长度最大是2048字节(Get请求)。

Firefox

65536

Safari

80000以上

Opera

190000字节以上

Chrome

8182字节

Apache Server

8192字节

IIS

16384字节

Perl HTTP::Daemon

至少8000字节

这里有一个有趣的测试: http://www.seomofo.com/experiments/title-and-h1-of-this-post-but-for-the-sake-of-keyword-prominence-stuffing-im-going-to-mention-it-again-using-various-synonyms-stemmed-variations-and-of-coursea-big-fat-prominent-font-size-heres-the-stumper-that-stumped-me-what-is-the-max-number-of-chars-in-a-url-that-google-is-willing-to-crawl-and-index-for-whatever-reason-i-thought-i-had-read-somewhere-that-googles-limit-on-urls-was-255-characters-but-that-turned-out-to-be-wrong-so-maybe-i-just-made-that-number-up-the-best-answer-i-could-find-was-this-quote-from-googles-webmaster-trends-analyst-john-mueller-we-can-certainly-crawl-and-index-urls-over-1000-characters-long-but-that-doesnt-mean-that-its-a-good-practice-the-setup-for-this-experiment-is-going-to-be-pretty-simple-im-going-to-edit-the-permalink-of-this-post-to-be-really-really-long-then-im-going-to-see-if-google-indexes-it-i-might-even-see-if-yahoo-and-bing-index-iteven-though-no-one-really-cares-what-those-assholes-are-doing-url-character-limits-unrelated-to-google-the-question-now-is-how-many-characters-should-i-make-the-url-of-this-post-there-are-a-couple-of-sources-ill-reference-to-help-me-make-this-decision-the-first-is-this-quote-from-the-microsoft-support-pages-microsoft-internet-explorer-has-a-maximum-uniform-resource-locator-url-length-of-2083-characters-internet-explorer-also-has-a-maximum-path-length-of-2048-characters-this-limit-applies-to-both-post-request-and-get-request-urls-the-second-source-ill-cite-is-the-http-11-protocol-which-says-the-http-protocol-does-not-place-any-a-priori-limit-on-the-length-of-a-uri-servers-must-be-able-to-handle-the-uri-of-any-resource-they-serve-and-should-be-able-to-handle-uris-of-unbounded-length-if-they-provide-get-based-forms-that-could-generate-such-uris-a-server-should-return-414-request-uri-too-long-status-if-a-uri-is-longer.html