access # part of the URL via PHP
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
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.
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?
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.
精彩评论