Hi, I have written a small php script which uses clean urls for which mod_rewrite rules are used. that script needs to know where is located in order to run.
- root domain : yourdomain.com
- sub dir yourdomain.com/subdir/
Currently to set path for the script. I use following two,
Case: root domain:
define("ScriptURl",'http://'.$_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF'])); define("ScriptUri",dirname($_SERVER['PHP_SELF']));
Case: SubDir:
define("ScriptUrls",'https://'.$_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF']).'/'); define("ScriptUrl",'http://'.$_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF']).'/'); define("ScriptUri",dirname($_SERVER['PHP_SELF']).'/')
Now, My question how can I detect is script is in subdir(yourdomain.com/subdir/) or root domain( yourdomain.com). Any way to do this in PHP or I have setup the config manually for each install?