简体   繁体   中英

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM