Friday 15 November 2013

PHP get the current URL

To get the actual URL (non necessarily the one shown in the address bar because of URL rewriting):

 
 
$actual_url = 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'];
 
To get the URL shown in the address bar:

$displayed_url = "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";

No comments:

Post a Comment