0

Say I have this url.

http://mydomain.local/category/12/garden#31/decking-treatment

Can the part after the # i.e 31/decking-treatment be retrieved on serverside?

I checked in the $_SERVER and $_REQUEST superglobals but it is not there.

Thanks

Regards Gabriel

hakre
  • 193,403
  • 52
  • 435
  • 836
Gabriel Spiteri
  • 4,896
  • 12
  • 43
  • 58

3 Answers3

5

Can the part after the # i.e 31/decking-treatment be retrieved on serverside?

No. It is handled client side and never sent to the server. That is why using it for JS based history instead of pushState is a bad idea.

Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335
1

No, everything after the # is only ever used client side and will not hit the server. If you were to encode the # character before pushing it to the server then you might be able to do something but it would be a little long winded. What is it you are trying to acheive overall?

Matt Seymour
  • 8,880
  • 7
  • 60
  • 101
  • Basically I have an ajax based menu. User clicks on an item of the menu and a div gets refreshed. Onclick .. I added the hash part to the url. Reason being that if the user shares the link with someone. I want the other person to see the same information. – Gabriel Spiteri Jul 22 '11 at 11:40
0

This is how I sort it:

function reloadPage()
    {
        var hash = location.hash;
        if (hash){
            hash = hash.replace('#', '');
            location.href = hash;
        }
    }

reloadPage();

include this in your js file.

Ignas
  • 1,965
  • 2
  • 17
  • 44