I have a configuration file. This is not a separate file. I will include this file at the top of the pages that I want to use using require (). I want to dynamically get the full absolute URL of this configuration file , regardless of its location, and save it as a constant inside myself. For instance:
Physical location: (root directory) /my_folder/configuration.php
Required URL like: www.mydomain.com/my_folder/configuration.php
Physical location: (root directory) /demos/my_folder/configuration.php
Required URL like: www.mydomain.com/demos/my_folder/configuration.php
Physical location: (root directory) /demos/site1/my_folder/configuration.php
Required URL like: www.mydomain.com/demos/site1/my_folder/configuration.php
Physical location: (root directory) /demos/site2/my_folder/configuration.php
Required URL like: www.mydomain.com/demos/site2/my_folder/configuration.php
Simple so far? This is what is really necessary and complicated (IMO). Consider this:
Configuration file located at: www.mydomain.com/demos/site2/my_folder/configuration.php
They have subfolders: www.mydomain.com/demos/site2/1/2/3/index.php
When I access the index.php file in a subfolder of "3", following the above URL, I need the path to the configuration file as www.mydomain.com/demos/site2/my_folder/configuration. php , not like www.mydomain.com/demos/site2/1/2/3/my_folder/configuration.php
How can I achieve the above?
source share