In HTML you can set your href to "/folder/page" and the starting / would go to the root-directory of your web application (meaning it would start at www.yoursite.com) and move on from there.
Now, in PHP, can i do this? I am having a problem, since i have a file, that ALWAYS needs to start at the root, and then go a folder down. I can't use relative paths, since it will be included in other pages and of thus, i wouldn't know how many layers to go up before i was in the root directory.
I tried using "$_SESSION['DOCUMENT_ROOT']" but that gives me an address too far up the directory tree. For example (on a test site) i have this URL: http://localhost:8888/kasseNet-BitBucet/
And i want THAT to be my root. Currently it's something like "Applications/Mamp/htdocs".
How can i achieve this? Obviously i could use an absolute path for this, but then it wouldn't be easy for me to launch it, since i would have to change it to not be on a localhost environment.
I have been googling my ass off, but i can't seem to find the right fit. It should be an easy task to accomplish.
For completeness sake, here is my structure:
(assuming we are in "root" - the localhost htdocs/site folder) - Login *Authenticate.php *login.php - Other *test.php - default.php
Now, both "default.php" and "test.php" will include the authenticate.php. The authenticate.php will redirect to the login.php. Now, the problem is that if i include it in the default.php, my path in the Authenticate.php file to the login.php would be "Login/Authenticate.php". BUT, if i include it in the test.php, i would have to do "../Login/Authenticate.php". This illustrates the problem, and it only gets worse as the structure grows.
As you can imagine, it is for a login script where i include the authenticate file, that will redirect to the login page if the user is not logged in. All the examples i've found though, just uses a flat structure with no extra directories, so they don't have that problem.
Hoping for some help, been stuck for days thinking of a solution xD
Thank you in advance. Best Regards /JBJ