본문 바로가기

StackOverflow

[HTML] 웹 브라우저에 입력할 수 있는 URL의 길이?

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


Q: 웹 브라우저에 입력할 수 있는 URL의 길이는 몇 글자이죠? 브라우저 별로 다른가요? HTTP 프로토콜에 그게 정해져 있나요? 

(질문자: Sander Versluys)


A: 짧게 답하자면, 실제 많이 쓰이고 있는 (de facto) 길이는 2000자 입니다.

길게 설명을 드리자면, RFC 2616 에 따르면: 제한은 없고, GET으로 URL을 통해 데이터 전달을 할 수도 있기 때문에 URL은 굉장히 길어질 수 있으며, 서버는 이걸 받아주어야 합니다.

RFC 7230에 따르면: 8000 octet 이상 가능해야 합니다. (역주: 1 octet = 8 bit. 실질적으로는 1 byte와 같은 의미인데, 특수한 경우에는 1 byte 를 8 bit 가 아닌 다른 값으로 정의한 시스템이 있기 때문에 엄밀한 의미로 8 bit 를 가리킬 때 1 octet 이라는 표현을 씀)

현실적으로는 boutell.com 에서 조사한 바에 따르면 영문 2000 글자입니다.

이 질문이 처음 올라온 것이 2009년 1월이고 이걸 현재(2015년 12월)까지 계속 업데이트하고 있는데, 아직 2000자 정도를 유지하는게 적절합니다. 아마 IE11이 그 이상을 지원할지도 모르지만, 하위호환성을 위해 2000자 정도를 유지하는 것이 좋습니다.

(답변자: Paul Dixon)



What is the maximum length of a URL in different browsers? Does it differ between browsers?

Does the HTTP protocol dictate it?

shareeditflag








----------------------------------------


up vote2694down voteaccepted

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).

That RFC has been obsoleted by RFC7230 which is a refresh of the HTTP/1.1 specification. It contains similar language, but also goes on to suggest this:

Various ad hoc limitations on request-line length are found in practice. It is RECOMMENDED that all HTTP senders and recipients support, at a minimum, request-line lengths of 8000 octets.

...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 browsers. Don't use them if you intend your site to work for the majority of Internet users.

(Note: this is a quote from an article written in 2006, but in 2015 IE's declining usage means that longer URLs do work for the majority. However, IE still has the limitation...)

Internet Explorer's limitations...

IE8's maximum URL length is 2083 chars, and it seems IE9 has a similar limit.

I've tested IE10 and the address bar will only accept 2083 chars. You can click a URL which is longer than this, but the address bar will still only show 2083 characters of this link.

There's a nice writeup on the IE Internals blog which goes into some of the background to this.

There are mixed reports IE11 supports longer URLS - see comments below. Given some people report issues, the general advice still stands.

Search engines like URLs < 2048 chars...

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.

Is this information up to date?

This is a popular question, and as the original research is ~9 years old I'll try to keep it up to date: As of Sep 2015, the advice still stands. Even though IE11 may possibly accept longer URLs, the ubiquity of older IE installations plus the search engine limitations mean staying under 2000 chars is the best general policy.

shareeditflag