1

My website is an iframe base website. it has following link,

localhost/folder/index.php/#!/post/

I can't figure out how to grab the "/#!/post/" part of the URL.

I am using the following php script to get url but its only get url till "index.php".

$pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];

Can anybody help me to get complete URL through PHP??? , I am new in development so not much know about the technicalities.

Hkachhia
  • 4,463
  • 6
  • 41
  • 76
Syed
  • 25
  • 1
  • 7
  • 1
    http://isolani.co.uk/blog/javascript/BreakingTheWebWithHashBangs is a worthwhile read. Don't use hashbangs, use the history api instead. – Quentin May 24 '13 at 06:43

3 Answers3

1

Hash fragments are not passed to the server; they are clientside-only. Since PHP is a serverside language, it will never be aware of them.

Chris Heald
  • 61,439
  • 10
  • 123
  • 137
0

The PHP will not use '#' (Fragment identifier), If you need the fragment identifier then get through the javascript like below

document.URL

If required send to PHP by posting through AJAX.

Vijay
  • 66
  • 6
0

You have to use Javascript for this. The segment after the # is not sent to server, so PHP can't retrieve that part.

In javascript you can use window.location while will give you localhost/folder/index.php/#!/post/

To get the hashed part only, you can use window.location.hash which will give you #!/post/.

sakibmoon
  • 2,026
  • 3
  • 22
  • 32