Reputation: 10956
I want to get the current page URL with parameters in PHP
the URL is
http://localhost/omni/abc.php#def=S6ZT4b9MEsFGDzo
I want to get the url part after the #
sign
Upvotes: 2
Views: 516
Reputation: 16065
From this URL: http://localhost/omni/abc.php?def=S6ZT4b9MEsFGDzo
$_SERVER['HTTP_HOST']
-> localhost
$_SERVER['SCRIPT_URL']
-> omni/abc.php
$_SERVER['QUERY_STRING']
-> def=S6ZT4b9MEsFGDzo
OR
$_SERVER['REQUEST_URI']
-> omni/abc.php?def=S6ZT4b9MEsFGDzo
OR
$_SERVER['SCRIPT_URI']
-> http://localhost/omni/abc.php
Upvotes: 0
Reputation: 23123
Found this little niblet while researching the issue...
http://www.stoimen.com/blog/2009/04/15/read-the-anchor-part-of-the-url-with-php/
<script>
var query = location.href.split('#');
document.cookies = 'anchor=' + query[1];
<?php if (!$_COOKIE['anchor']) : ?>
window.location.reload();
<?php endif; ?>
<?php
echo $_COOKIE['anchor'];
?>
Upvotes: 0
Reputation: 20269
Anything after the #
in a URL is only handled on the client-side. It is not even passed to the request to the server, so there is no way you can directly access it.
Upvotes: 4