enne87
enne87

Reputation: 2299

Read url from browser

I have the following url: http://raiffeisenclub.www4.nextsoft.at/# bereich=6&_suid=132023551036703093549711221371 and I want to get this url via php. I tried it with

$_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];

but I just get http://raiffeisenclub.www4.nextsoft.at then. Also

$_SERVER['QUERY_STRING']; 

and

$_SERVER['REQUEST_URI'];

don't work. Can someone give me a hint please?

Upvotes: 2

Views: 535

Answers (2)

Maxim Krizhanovsky
Maxim Krizhanovsky

Reputation: 26719

Browser do not send the hash (the part after #) to the server, and because of this it is not available in PHP. You can read it and send it to the server only with JavaScript

When a URI reference is used to perform a retrieval action on the identified resource, the optional fragment identifier, separated from the URI by a crosshatch ("#") character, consists of additional reference information to be interpreted by the user agent after the retrieval action has been successfully completed. As such, it is not part of a URI, but is often used in conjunction with a URI.

source

Upvotes: 4

Mohit Bumb
Mohit Bumb

Reputation: 2493

Try with javascript

<script language="javascript" type="text/javascript">
var pageurl = document.location.href;
</script>

Upvotes: 1

Related Questions