Sorin Buturugeanu
Sorin Buturugeanu

Reputation: 1122

What characters can one use in a URL?

I have an application that takes all the parameters in the url like this: /category/subcategory/sub-subcategory. I want to be able to give out extra parameters at the end of the URL, like page-2/order-desc. This would make the whole URL into cat/subcat/sub-subcat{delimiting-character}page-2/order-desc.

My question is: what characters could I use as {delimiting-character}. I tend to prefer ":" as I know for sure it will never appear anyplace else but I don't know if it would be standard compliant or at least if it will not give me problems in the future.

As I recall vimeo used something like this: vimeo.com/video:{code} but they seem to have changed this.

Upvotes: 20

Views: 54938

Answers (5)

Adam Klein
Adam Klein

Reputation: 11

If you use dash or underscore, remember that a dash is read by Google as a hyphen, so does not alter how your URL is categorized. An underscore is counted as a character, and can mess up your SEO.

Ex: dash-use = dash use (2 words); underscore_use = underscore_use (1 word)

Upvotes: 1

andrew
andrew

Reputation: 2098

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

Upvotes: 26

McDowell
McDowell

Reputation: 108859

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    = "!" / "$" / "&" / "'" / "(" / ")"
                      / "*" / "+" / "," / ";" / "="

Upvotes: 8

alexyorke
alexyorke

Reputation: 4299

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.

Upvotes: 0

James L
James L

Reputation: 16854

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

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

Upvotes: 2

Related Questions