简体   繁体   English

使用Apache访问文档根目录外的文件

[英]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). /a/b/c/d/e/f/g/h/mywebsite.com(字母中有正确的名称)。

The file I need to read lives here: 我需要阅读的文件存在于此处:

/a/b/c/myfile.txt /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. 请注意,这需要在中央配置文件中进行,而不是在.htaccess文件中进行。

Symlinks are an option too. 符号链接也是一种选择。 Make sure you have 确保你有

Options +FollowSymlinks

turned on. 打开。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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