/ Published in: PHP
Get Current URL Path on Apache / IIS
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
// On Apache -> function selfURL() { : ($_SERVER["HTTPS"] == "on") ? "s" : ""; $port = ($_SERVER["SERVER_PORT"] == "80") ? "" : (":".$_SERVER["SERVER_PORT"]); return $protocol."://".$_SERVER['SERVER_NAME'].$port.$_SERVER['REQUEST_URI']; } function strleft($s1, $s2) { } // On IIS -> function selfURL(){ $serverrequri = $_SERVER['PHP_SELF']; }else{ $serverrequri = $_SERVER['REQUEST_URI']; } $port = ($_SERVER["SERVER_PORT"] == "80") ? "" : (":".$_SERVER["SERVER_PORT"]); return $protocol."://".$_SERVER['SERVER_NAME'].$port.$serverrequri; } // Get Current URL -> print(selfURL());
URL: http://dev.kanngard.net/Permalinks/ID_20050507183447.html