I have a configuration file. This is not a stand-alone file. I will be including this file at the top of the pages that I want to use in, using require(). I want to dynamically get the complete absolute url path to this configuration file, regardless of it's location and store it as a constant within itself. For example:
Physical Location: (root dir)/my_folder/configuration.php
Need URL as: www.mydomain.com/my_folder/configuration.php
Physical Location: (root dir)/demos/my_folder/configuration.php
Need URL as: www.mydomain.com/demos/my_folder/configuration.php
Physical Location: (root dir)/demos/site1/my_folder/configuration.php
Need URL as: www.mydomain.com/demos/site1/my_folder/configuration.php
Physical Location: (root dir)/demos/site2/my_folder/configuration.php
Need URL as: www.mydomain.com/demos/site2/my_folder/configuration.php
Simple so far? Here's what really needed and makes it complicated (IMO). Consider this:
Config file located at: www.mydomain.com/demos/site2/my_folder/configuration.php
Have nested folders: www.mydomain.com/demos/site2/1/2/3/index.php
When I access the index.php file in the "3" sub-folder by following the URL above, I need the path to configuration file as www.mydomain.com/demos/site2/my_folder/configuration.php and not as www.mydomain.com/demos/site2/1/2/3/my_folder/configuration.php
How can I achieve the above?