[php] Why is the hash part of the URL not available on the server side?


Answers

http://tools.ietf.org/html/rfc2396#section-4

When a URI reference is used to perform a retrieval action on the identified resource, the optional fragment identifier, separated from the URI by a crosshatch ("#") character, consists of additional reference information to be interpreted by the user agent after the retrieval action has been successfully completed. As such, it is not part of a URI, but is often used in conjunction with a URI.

Question

For example if I type in the URL:

http://www.foo.com/page.php?parameter=kickme#MOREURL

Then on the server there is no part: #MOREURL

Is possible to send or get these part to the server without jQuery AJAX?.




I would like to extend the answer on the reason WHY the fragment is not sent to the server. Because it is intentional and desired behavior. Let's look at URL string in whole.

/path/to/element?query=string&for=server#?optional=fragment&for=browser <----- URI ----> <---- QUERY STRING ---> <----- FRAGMENT STRING ------>

URI uniquely specifies resource fetched from a server

QUERY defines operations to be performed by the server on the resource

FRAGMENT controls browser (application) behavior. Fragment should be used to store application state which should be visible to the user so the user can send link to another user to get the same application state.

Fragment is the only part of URL free for you to transparently implement single-page web applications (which can run offline on your mobile phone for example). Therefore it must not be sent to the server.




Links