Accessing files outside the document root with Apache

diggersworld picture diggersworld · Apr 6, 2011 · Viewed 23.5k times · Source

I have a project setup and i'm trying to access a file from a temp folder on the server.

The document root for the website is similar to this:

/a/b/c/d/e/f/g/h/mywebsite.com (of the letters have proper names).

The file I need to read lives here:

/a/b/c/myfile.txt

I've tried symbolic links but may have done them wrong... any ideas?

Answer

Pekka picture Pekka · Apr 6, 2011

You can create a directory alias:

<VirtualHost....>

..... stuff .....

Alias /mydir /a/b/c

</VirtualHost>

then you could access the text file like so:

domain.com/mydir/myfile.txt

Note that this needs to take place in the central configuration file, not a .htaccess file.

Symlinks are an option too. Make sure you have

Options +FollowSymlinks

turned on.