1<?php
2 if(isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on')
3 $url = "https://";
4 else
5 $url = "http://";
6 // Append the host(domain name, ip) to the URL.
7 $url.= $_SERVER['HTTP_HOST'];
8
9 // Append the requested resource location to the URL
10 $url.= $_SERVER['REQUEST_URI'];
11
12 echo $url;
13 ?>