Skip to content Skip to sidebar Skip to footer

Setting A Root Directory For Accessing Files From Subfolders?

I am trying to create a root directory on my localhost(using xampp) so that I can link to images and folders found on the root from subfolders. So my directory is built like seen b

Solution 1:

$_SERVER['DOCUMENT_ROOT'] gives you the real file-system path, not the path returned by Apache.

To link to the resource you need to use the HTTP path. If you want to link from the root you just need something like /images/logo.jpg

Solution 2:

I found that on my PHPBB3.1 driven website using the "Pages" addin, the relative link would not remain 'static' in some link buttons at the top of my site.

From the PHPbb3 index page a link such as app.php/page/FT would produce an address of http://earth/forum/app.php/page/FT (Correct) ,but from the "Pages add in) that same link produced http://earth/forum/app.php/page/app.php/page/FT (incorrect).

I started looking for a way to set my page relative to the root of the web. I could NOT use absolute links because my site is replicated on other servers. I found the answer by trial and error. Simply add several ../../../ like this ../../../forum/app.php/page/FT and it works.

Perhaps not the best of computer programming but it does the job. In a nutshell with each ../ you step back a directory, put too many in and it goes back to the root but cannot go back any further!

Post a Comment for "Setting A Root Directory For Accessing Files From Subfolders?"