You can't. That data, called the fragment, is reserved for client side processing and thus is never sent to the server.
The only way to utilize the fragment is to have Javascript intervene at some point. This probably means checking for a hash-tag on the page onload
, and then displaying the proper data.
You could make your entire page loaded via Javascript. While it would kill compatability for anyone who turned off Javascript, it would ensure that the hash tag eventually gets sent to PHP
Basically, it would look something like this:
- PHP Sends Page
- Javascript reads the hastag
- Make a URL with a hashtag parameter (loader.php?page=list&page=news)
(Note that in the above, page=list
wil be overriden by page=news
, so $_GET['page']
will be news
.
- AJAX call to PHP
- Load the content into a div.
(And this question is very much a duplicate question)