Quantcast
Channel: Hacker News 50
Viewing all articles
Browse latest Browse all 9433

http - What is the maximum length of a URL? - Stack Overflow

$
0
0

Comments:"http - What is the maximum length of a URL? - Stack Overflow"

URL:http://stackoverflow.com/questions/417142/what-is-the-maximum-length-of-a-url


Short answer - de facto limit of 2000 characters

If you keep URLs under 2000 characters, they'll work in virtually any combination of client and server software.

Longer answer - first, the standards...

RFC 2616 (Hypertext Transfer Protocol HTTP/1.1) section 3.2.1 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 than the server can handle (see section 10.4.15). Note: Servers ought to be cautious about depending on URI lengths above 255 bytes, because some older client or proxy implementations might not properly support these lengths.

...and the reality

That's what the standards say. For the reality, see this research over at boutell.com to see what individual browser and server implementations will support. It's worth a read, but the executive summary is:

Extremely long URLs are usually a mistake. URLs over 2,000 characters will not work in the most popular web browser. Don't use them if you intend your site to work for the majority of Internet users.

Also, be aware that the sitemaps protocol, which allows a site to inform search engines about available pages, has a limit of 2048 characters in a URL. If you intend to use sitemaps, a limit has been decided for you! (see Calin-Andrei Burloiu's answer below)

There's also some research from 2010 into the maximum URL length that search engines will crawl and index. They found the limit was 2047 chars, which appears allied to the sitemap protocol spec. However, they also found the Google SERP tool wouldn't cope with URLs longer than 1855 chars.

Footnote

This is a popular question, and as the original research is nearly 6 years old I'll try to keep it up to date: As of Jan 2013, the advice still stands, as IE8's maximum URL length is 2083 chars, and it seems IE9 has a similar limit.


Viewing all articles
Browse latest Browse all 9433

Trending Articles