You cannot. Anything in the fragment (the portion from the #
onwards) is not sent to the server. Only the client can look at that, which you can do in javascript via window.location.hash
.
One useful trick that some sites use, is to use the fragment to prevent user data appearing in http request logs; the page might be /foo/bar#something
, which loads /foo/bar
, then client-side javascript looks at the fragment and does an ajax POST to get data to load the content. This works because most http logs record the GET uri but not POST form bodies, so the #something
isn't captured in the logs.