I want to get URL of my script as i will create a config file with my installer and save that url in databse for some reason. But i cant get exact URL of my script. I tried $_SERVER['SCRIPTNAME'], $_SERVER['SCRIPT_FILENAME'], $_SERVER['HOST']. I dont know how cms like joomla and wordpress get it accurately whether m on localhost with sub directories in it or either on subdomains on live hosting.