Behavior When Only ?query Is Described in the href Attribute

Asked 3 months ago, Updated 3 months ago, 5 views (does not need to be PHP)


<a href="?foo=bar">?foo=bar</a>
<a href="?fizz=buzz">?fizz=buzz</a>

At this time, any user agent you have (Chrome 41, w3m/0.5.3, GNU Wget 1.13.4) expands the link as follows:

  • "?foo=bar"=>
  • "?fizz=buzz"=>

Is there any support from HTML or related standards for this behavior?Or is it just a user agent implementation practice?


2022-09-30 11:24

1 Answers

RFC 3986 Uniform Resource Identifier (URI): Generic Syntax. (RFC3986 Japanese translation)

The algorithm for resolving relative URIs is found in 55.2.Relative Resolution に.Also, the actual example is in "5.4. Reference Resolution Examples", so I'll skip it.

Within a presentation with a well defined base URI of


5.4.1.Normal Examples

a relative reference is transformed to its target URI as follows.

"?y" = "http://a/b/c/d;p?y"
"g?y" = "http://a/b/c/g?y"

Therefore, each user agent behaves according to the specifications of RFC 3986.

2022-09-30 11:24

If you have any answers or tips

© 2023 OneMinuteCode. All rights reserved.