title: What is a safe maximum length a segment in a URL path should be?
body: <p>A lot of people are asking <em>"What is the maximum length a <strong>URL</strong> can be?"</em> but as far as I can see nobody is asking the question:</p>
  
  <blockquote>
    <p>What is a safe maximum length a segment in a URL path should be?</p>
  </blockquote>
  
  <p>I think this question is equally as important.</p>
  
  <p>This question is a general question aimed at supporting as many systems out of the box as possible.</p>
  
  <p>In C#, you can get a list of URL path segments from an incoming request, with security modules installed what is considered the maximum length a segment in a URL path can be for this scenario?</p>
  
  <p>I've read on the following page that URL path segments over 260 characters can cause problems in custom ASP.NET modules:</p>
  
  <ul>
  <li><a href="http://www.paraesthesia.com/archive/2011/08/26/long-url-path-segments-in-asp-net-routing-yield-400.aspx/" rel="noreferrer">http://www.paraesthesia.com/archive/2011/08/26/long-url-path-segments-in-asp-net-routing-yield-400.aspx/</a></li>
  </ul>
  
  <p>In web browsers, you type URL segments regardless of what website you visit, <code>/</code> is a URL path segment which is usually mapped to a homepage. With Internet Explorer, Chrome and Firefox being popular browsers, what is the maximum length of a URL path segment length they support?</p>
  
  <p>I can see from the following resource that the maximum length of a URL path differs for different browsers and the figure is sometimes quite high:</p>
  
  <ul>
  <li><a href="https://stackoverflow.com/questions/1289585/what-is-apaches-maximum-url-length">What is apache&#39;s maximum url length?</a></li>
  </ul>
  
  <p>But this is a path and not a path segment.</p>
  
  <p>I'm also aware that when rewriting paths, the underlying file system path length comes into play, and the ball park figure of what I can see supported is around 255 characters in a *nix OS.</p>
  
  <p>Other considerations include the maximum length of a URL path segment in a database table. For instance, in MySQL a varchar column can contain up to 255 characters, but is there a case for this, are people storing segments of paths in tables in MySQL or are people storing full URL's in varchar columns? Could this mean 255 characters is too long for a URL path segment?</p>
  
  <p>Is there any W3C specification on how long a URL path segment can be as I can't spot anything?</p>
  
  <p>I did read the W3C specification on URI's but again I didn't spot anything of use:</p>
  
  <ul>
  <li><a href="http://www.ietf.org/rfc/rfc2396.txt" rel="noreferrer">http://www.ietf.org/rfc/rfc2396.txt</a></li>
  </ul>
  
  <p>I'm quite baffled that there is no set standard on what a length a URL path segment should be, so maybe I am missing something?</p>
  
  <p>I'm really looking for as much information as possible on what different systems support, and what is considered a safe length for a URL path segment.</p>