benphp Posted March 28, 2013 Share Posted March 28, 2013 This is an easy one for you masters. I find it a PIA - http://myserver/calendar/events.php I want: http://myserver/calendar/ or http://myserver/calendar ? Quote Link to comment https://forums.phpfreaks.com/topic/276273-how-to-fetch-current-url-without-page/ Share on other sites More sharing options...
Solution PaulRyan Posted March 28, 2013 Solution Share Posted March 28, 2013 (edited) <?PHP function getPath() { $protocol = strpos(strtolower($_SERVER['SERVER_PROTOCOL']),'https') === FALSE ? 'http' : 'https'; $host = $_SERVER['HTTP_HOST']; $path = substr($_SERVER['SCRIPT_NAME'], 0, -strlen(basename($_SERVER['SCRIPT_NAME']))); return $protocol.'://'.$host.$path; } echo getPath(); ?> Edited March 28, 2013 by PaulRyan Quote Link to comment https://forums.phpfreaks.com/topic/276273-how-to-fetch-current-url-without-page/#findComment-1421646 Share on other sites More sharing options...
benphp Posted March 28, 2013 Author Share Posted March 28, 2013 Thankyou! Quote Link to comment https://forums.phpfreaks.com/topic/276273-how-to-fetch-current-url-without-page/#findComment-1421661 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.