Obtaining URL hash server-side

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
Eran
DevNet Master
Posts: 3549
Joined: Fri Jan 18, 2008 12:36 am
Location: Israel, ME

Obtaining URL hash server-side

Post by Eran »

I need to retrieve the complete URL as it appears in the browser, including information after the hash sign (#). Unfortunately, $_SERVER['REQUEST_URI'] contains the URL without the hash. Does anybody has an idea on how to fetch it server-side? is this even possible?
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Obtaining URL hash server-side

Post by requinix »

Not sure if you can get that. Print out the $_SERVER array and see if anything works for you.
User avatar
Eran
DevNet Master
Posts: 3549
Joined: Fri Jan 18, 2008 12:36 am
Location: Israel, ME

Re: Obtaining URL hash server-side

Post by Eran »

Already done that, it's not available there or in apache_request_headers()
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: Obtaining URL hash server-side

Post by Christopher »

I don't think you can get it that way. The "#" is the fragment identifier. It is part of the URI, but not part of the URL. I don't think the browser even passes it.

You probably need to do some Javascript thing by having the browser identify the fragment and add it somehow to the URL or communicated it some other way (Ajax?).
(#10850)
User avatar
Eran
DevNet Master
Posts: 3549
Joined: Fri Jan 18, 2008 12:36 am
Location: Israel, ME

Re: Obtaining URL hash server-side

Post by Eran »

I was fearing it would be something like this. Quite troublesome...
Post Reply