I have a single page PHP app and use my urls as follows with a hashbang:
- http://www.example.com/
- http://www.example.com/#!/ (if coming to the homepage from another url below)
- http://www.example.com/#!/aboutus
- http://www.example.com/#!/contact
Now I'd like to display content only on my homepage and to do so I need to check if the URL contains a hashbang AND if it's empty, i.e.: If the user visited the homepage and if the user came back to the homepage after visiting another section (which applies the hashbang to it).
I've tried the following however it doesn't display the hashbang part, only if I set the url in the $curr_url
variable.
$curr_url = "http://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
//only gets the url part before the /#!/
$url=parse_url($curr_url);
echo $url["fragment"];