What characters can one use in a URL?

淺唱寂寞╮ 提交于 2019-12-04 00:11:06

You can use alphanumeric, plus the special characters "$-_.+!*'()," More info here: http://www.ietf.org/rfc/rfc1738.txt

Also, take note not to exceed 2000 characters in url

The most recent URI spec is RFC 3986; see the ABNF for details on what characters are allowed in which parts for the URI.

The format for an absolute path part is:

  path-absolute = "/" [ segment-nz *( "/" segment ) ]
  segment       = *pchar
  segment-nz    = 1*pchar
  pchar         = unreserved / pct-encoded / sub-delims / ":" / "@"
  pct-encoded   = "%" HEXDIG HEXDIG
  unreserved    = ALPHA / DIGIT / "-" / "." / "_" / "~"
  sub-delims    = "!" / "$" / "&" / "'" / "(" / ")"
                      / "*" / "+" / "," / ";" / "="

See http://www.ietf.org/rfc/rfc1738.txt

Basically, you are allowed all aphanumerics as well as $ - _ . + ! * ' ( ) ,

You could use a dash or an underscore (these are used frequently). You could use any character you want to but for example, spaces turn into %20 in the url so they don't look too-nice.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!