How to get the current URL of the current file in PHP

1 Answer

0 votes
$current_url = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? "https" : "http") .
               "://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
               
echo $current_url;

/*
run:

https://www.allonpage.com/abc/xyz/filename.php

*/

 



answered Dec 17, 2018 by avibootz

Related questions

1 answer 272 views
2 answers 318 views
318 views asked Jun 14, 2018 by avibootz
2 answers 393 views
1 answer 270 views
2 answers 423 views
1 answer 268 views
...