Hi there everyone,
During the site design process, I often go from accessing a site via http://server.com/client.com to http://client.com. So sometimes the files are accessed via the root URL(client.com) and sometimes from a subdirectory(server.com/client.com). This is causing me big headaches.
To add to my requirement, I try to access a single global header.php from files both in the root directory and subdirectories. I have been trying for some time now to come up with a method of determining the proper directory's URL and server path.
I've been playing with:
$rootpath = dirname(dirname(__FILE__));
$rooturl = dirname(dirname('http://' . $_SERVER['SERVER_NAME'] . $_SERVER['PHP_SELF']));
This works fine in a subdirectory but breaks when I use this in the root directory.
I know I could resolve this in the normal inelegant method of using different header files or if/else statements, but I was hoping someone could help me figure out a single and pretty resolution on how to get the proper URL and path for a file based on the URL being used to access the parent file.
Any help or suggestions would be greatly appreciated!
json