<?php echo "http://" . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']; 
echo "<br>";
echo $getpage=$_SERVER['REQUEST_URI'];
$getpage=explode("/",$_SERVER['REQUEST_URI']);
echo "<br>";
echo $makeurl="http://".$_SERVER['SERVER_NAME']."/".$getpage[1]."/".$_REQUEST['pagename'].".php";
?>