Get Full Current URL from Address Bar

In this tutorial, you’ll learn how to get current web page URL from your web browser address bar using PHP script.

To get Current Page URL We can use $_SERVER Environment variables.

In PHP, We can not read URL path after hash(#) tag. Because browser does not send the hash data to the server. You can get #tag data only with JavaScript.

if the Website running on standard port (80,443) web site current URL will be,

if the website running under non-standard port, current URL will be,

i am gonna convert this script into standard function :

Using JavaScript : you can get current page URL from the address bar using below script

Useful Environment variables of URL:

$_SERVER[‘HTTP_HOST’] = Host name from the current request.
$_SERVER[‘HTTP’] = Set to a non-empty value if the protocol is HTTP
$_SERVER[‘HTTPS’] = Set to a non-empty value if the protocol is HTTPS
$_SERVER[‘SERVER_PORT’] = Server port. Default is: 80
$_SERVER[‘REQUEST_URI’] = The URI to access this page,For example, ‘/index.php’.

I hope you like this Post, Please feel free to comment below, your suggestion and problems if you face - we are here to solve your problems.

0 0 vote
Article Rating
Notify of
Inline Feedbacks
View all comments Protection Status
Would love your thoughts, please comment.x