Can any segment of the URI path have a request component?

According to Section 3.3, RFC2396 Path Component - Unified Resource Identifiers ,

A path can consist of a sequence of path segments separated by a single slash "/" character. Within the path segment, the characters "/", ";", "=" and "?" reserved. Each path segment may include a sequence of parameters indicated by a semicolon ";" character. Parameters are not essential for parsing relative links.

However, I have never seen a URL with request parameters in any segment other than the last. So, I'm not sure if I am reading correctly.

Is a http://www.url.com/segment1?seg1param1=val1/page.html?pageparam1=val2valid URL?

+5
source share
4 answers

What the RFC means is something like this:

http://www.example.com/foo/bar;param=value/baz.html

This can be interpreted as a path /foo/bar/baz.htmlwith a parameter param=valueto the segment bar. No question marks are used.

Note that RFC 2396 is deprecated by RFC 3986 , which omits the specification of segment parameters in favor of a general note that implementations can (and do) do different things to embed segment-specific parameters:

,    . URI    , ,    , .   , ( ";" ) ( "=" )    ,    . ( "," )    . , URI    "name; v = 1.1", 1.1    "name", , "name, 1.1" to    .   ,    URI.

+8

, , :

  path          = [ abs_path | opaque_part ]

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

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

pchar param, param pchar. , ? pchar. , "?" , "?" .

, , , "?" .

+1

RFC 2396, . ? . ? , .

? . ? .

0
source

I believe that you can handle this and most web servers will handle it, but I do not believe that you will get the expected results. That is, the parameter pageparam1 = val2 will not be evaluated.

If you need such parameters, you can always use the # character (as many javascript-based graphical interfaces do).

0
source

All Articles