I\'d like to find the base url of my application, so I can automatically reference other files in my application tree...
So given a file config.php in the base of my
url root of the application can be found by
$protocol = (strstr('https',$_SERVER['SERVER_PROTOCOL']) === false)?'http':'https';
$url = $protocol.'://'.$_SERVER['SERVER_NAME'].dirname($_SERVER['REQUEST_URI']);
this code will return url path of any application whether be online or on offline server.
I've not made proper check for proper '/'. Please modify it for slashes.
this file should be placed in root.
example : if application url :
http://localhost/test/test/test.php
then this code will return
http://localhost/test/test
Thanks