When both a query string and anchor tag (hash tag) are visible in a URL, what is the proper order for them to appear?
http://www.whatever.com?var=val#anchor
or
http://www.whatever.com#anchor?var=val
Is there any documentation on this?
update: The URLs are being handled by Wordpress / PHP
everything after
#
is client side.Also, look into url rewriting to get rid of ugly
?var=var
Note that when the URL has both anchor tags (#) and query strings (?), the browser may ignore the query string and navigate to the anchor tag without reloading the page.
It may be necessary to submit the page using a
rather than just a URL link
? should come before the # as noted in RFC 3986:
Taken from an answer over at superuser (https://superuser.com/questions/498617/does-an-anchor-tag-come-before-the-query-string-or-after):
If intention of using
#
is to denote pagefragment
then - yes?
then#
.If
#
is coming before?
and it is not to denote pagefragment
(this can happen when#
is part of authority (username and password)) it has to be encoded or you are in trouble. Same applies to any other special characters (:
,@
,...) that could give different meaning to url.