2

My URL looks like this:

http://mydomain.com/reader/index.php?type=numerated&id=28&m=2#page/6/mode/2up

How can I get it like variable? Using "standard" PHP codding, I don't know how to get part with page/6/mode/2up

Looks like minor problem, but I was not able to get solution... Thank you in advance!

user198003
  • 11,029
  • 28
  • 94
  • 152
  • You can't, because in most cases the browser doesn't pass the # or anything after it to the server – Mark Baker May 14 '12 at 19:53
  • 1
    If you're asking about parsing that url as a string [this question should help](http://stackoverflow.com/questions/2940508/regex-to-get-value-of-a-numeric-url-parameter/2940540#2940540). – Mike B May 14 '12 at 19:54

1 Answers1

5

The part after # is a client-side part of the URL, it refers to an anchor within the HTML. Therefore, you can only retrieve everything before that.

Clients are not supposed to send URI-fragments to servers when they retrieve a document, and without help from a local application fragments do not participate in HTTP redirections.

~ Wikipedia: http://en.wikipedia.org/wiki/Fragment_identifier


To retrieve everything else, you can use this code:

$url = "http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
Jeroen
  • 13,056
  • 4
  • 42
  • 63