Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Accessing files outside the document root with Apache

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?

like image 839
diggersworld Avatar asked Apr 06 '11 16:04

diggersworld


People also ask

What is the document root for Apache?

The DocumentRoot is the top-level directory in the document tree visible from the web and this directive sets the directory in the configuration from which Apache2 or HTTPD looks for and serves web files from the requested URL to the document root.

Where is my Apache document root?

On Ubuntu, the Apache web server serves documents stored in the var/www/html directory by default. This directory is referred to as the document root.


1 Answers

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.

like image 65
Pekka Avatar answered Oct 02 '22 10:10

Pekka