1

Specifically. I am making an ajax app and trying to preserve the back button. My javascript is working properly and registering a new url in the address bar with an anchor-like hash in the url:

http://t2b.localhost/#/clients/

I can catch the url when the page loads with javascript and load the "clients" page, but I want to know if there is a way to read the entire url with php or with htaccess? Looking at normal variables, I seem to only be able to get the url up to the occurrence of the "#" (http://t2b.localhost/).

Jage
  • 7,714
  • 3
  • 29
  • 30

4 Answers4

4

The browser don't send to the server the fragment (the text after the #) part of the url. It is intended to be used locally by the client.

In firefox (and in explorer too) there is document.location.hash that contains the fragment part of the URL. If you use javascript you can read it and send his value into a common variable.

Eineki
  • 14,008
  • 6
  • 47
  • 54
1

Please use any of the available javascript libraries to track the history state or browse by ajax requests. There are so many problems involved, such as certain browsers not notifying scripts when the hash part changes, or not adding a pseudo-'navigation' event to the browser's history list etc., that you'll end up recreating an expensive wheel that wouldn't work very well. I recommend YUI's History library, although it has problems on Google Chrome.

lifeforms
  • 61
  • 4
0

I'm pretty sure that you can't parse it strictly with PHP because the hash part is parsed only on the client-side ( Javascript ).

For history I'd recommend Ben Alman's BBQ plugin.

See: Can I read the hash portion of the URL on my server-side application (PHP, Ruby, Python, etc.)?

Community
  • 1
  • 1
meder omuraliev
  • 171,706
  • 64
  • 370
  • 423
0

You could use javascript and set a cookie as the current URL then get it with PHP

Galen
  • 29,108
  • 8
  • 66
  • 88