13

I'm calling a web service in this format:

http://some.server/rest/resource;a=b

It works but is this valid? I've seen the ; used as a replacement for the & but never seen such an url. I've been looking for an answer but did not find a valid one. If valid what is the meaning of this kind of url?

1

3 Answers 3

17

This is a part of the path parameters and not part of the query parameters. You can find detailed information on how URLs can be built at http://www.skorks.com/2010/05/what-every-developer-should-know-about-urls/

Edit: I was actually looking for this link earlier which explains it even better and shows you some weird but valid cases: https://www.talisman.org/~erlkonig/misc/lunatech%5Ewhat-every-webdev-must-know-about-url-encoding/ (originally at the now dead url http://blog.lunatech.com/2009/02/03/what-every-web-developer-must-know-about-url-encoding)

But anyway, this is valid: http://www.blah.com/some/crazy/path.html;param1=foo;param2=bar

2
  • your second link is dead :(
    – drs
    Jul 20, 2016 at 13:06
  • Just to let anyone know that although the certificate is invalid, the talisman url still works in 2019
    – franksands
    Feb 25, 2019 at 14:29
3

RFC2396 where path parameters were specified is obsolete. newer version is RFC 3986 -- this one does not have path parameters before the query string formally specified, however still has it in section 5.4.1 in examples.

4
  • 1
    While this link may assist in your answer to the question, you can improve this answer by taking vital parts of the link and putting it into your answer, this makes sure your answer is still an answer if the link gets changed or removed :) Feb 8, 2018 at 13:20
  • link was removed. RFC number should be suffice. Feb 9, 2018 at 14:14
  • 1
  • I ended up here with a similar question about using a semicolon to add more params at the end of a url and found my answer in this RFC section datatracker.ietf.org/doc/html/rfc3986#section-3.3
    – A.J.
    Dec 20, 2023 at 18:37
0

This might answer your question: Semicolon as URL query separator

We recommend that HTTP server implementors, and in particular, CGI implementors support the use of ";" in place of "&" to save authors the trouble of escaping "&" characters in this manner.

2
  • 2
    In my example the semicolon is used not in place of "&" but in place of "?" Sep 16, 2013 at 14:19
  • 1
    @aCa: Your link is still about the query part, while his example is actually about path parameters. Sep 16, 2013 at 14:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.