[ACCEPTED]-Can any path segments of a URI have a query component?-rfc2396

Accepted answer
Score: 15

What the RFC is referring to is something 27 like this:


That could be interpreted as the 26 path /foo/bar/baz.html with the parameter param=value to the bar segment. No 25 question marks are used.

Note that RFC 2396 24 has been obsoleted by RFC 3986, which omits specification 23 of segment-specific parameters in favor 22 of a general note that implementations can 21 (and do) do different things to embed segment-specific 20 parameters:

Aside from dot-segments in hierarchical 19 paths, a path segment is considered 18 opaque by the generic syntax. URI producing 17 applications often use the reserved 16 characters allowed in a segment to delimit scheme-specific 15 or dereference-handler-specific subcomponents. For example, the 14 semicolon (";") and equals ("=") reserved 13 characters are often used to delimit 12 parameters and parameter values applicable 11 to that segment. The comma (",") reserved 10 character is often used for similar 9 purposes. For example, one URI producer 8 might use a segment such as "name;v=1.1" to 7 indicate a reference to version 1.1 of "name", whereas 6 another might use a segment such as "name,1.1" to indicate 5 the same. Parameter types may be defined 4 by scheme-specific semantics, but in 3 most cases the syntax of a parameter is 2 specific to the implementation of the 1 URI's dereferencing algorithm.

Score: 1

When you look at the grammar which is just 10 below, it is written:

  path          = [ abs_path | opaque_part ]

  path_segments = segment *( "/" segment )
  segment       = *pchar *( ";" param )
  param         = *pchar

  pchar         = unreserved | escaped |
                  ":" | "@" | "&" | "=" | "+" | "$" | ","

A segment is composed 9 of pchar and param, param being itself a 8 pchar. When we continue to read, there is 7 absolutely no "?" character in the pchar 6 character components. So the parameters 5 cannot have any "?", and there cannot be 4 a "?" in segments.

So I agree with the answer 3 of Edward Thomson, who says that "?" only 2 delimit the query segment, and cannot be 1 used inside a path.

Score: 0

According to my reading of RFC 2396, no. The 7 ? is a reserved character and serves only 6 to delimit the query segment. The ? is not 5 allowed in either the path or the query 4 segment.

In your example, the first ? marks 3 the beginning of the query segment. The 2 second ? is inside the query segment, and 1 is disallowed.

Score: 0

I believe you could do a get with that and 6 most web servers would process it but I 5 don't believe you would get the results 4 you are expecting. That is the pageparam1=val2 3 would not evaluate.

If you want parameters 2 like that you could always use the # symbol 1 (as a lot of javascript based GUIs do now).

More Related questions