Rohit Banga
Rohit Banga

Reputation: 18926

http url input parameters

Is this a valid http url

http://www.example.com?x&y

or

we must always have = sign for parameters.

http://www.example.com?x1=x&x2=y

Upvotes: 2

Views: 2293

Answers (2)

Franci Penov
Franci Penov

Reputation: 76021

According to the ABNF in Appendix A of RFC 3986, both examples above are valid URL.

Note that if you read only the Wikipedia article on Query string, you might get the false impression that the second ne is the only valid one.

Upvotes: 1

Devin Ceartas
Devin Ceartas

Reputation: 4829

Well, it works, and the W3C recommendations are extremely general -- only the use of ? and + are defined. So I think from the perspective of HTTP/HTML the = is optional. It's use is obviously a common convention and many client & server libraries use it, but there doesn't seem to be any reason you couldn't define a service to work on some other scheme.

Anecdotally, I like to leave out the =blah part when I'm using the query string as a flag as in http://www.example.com?logout

Reference: http://www.w3.org/Addressing/URL/4_URI_Recommentations.html

Upvotes: 2

Related Questions