HTTP URL最大長度

來源:互聯網
上載者:User

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

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.