Linux 使用 Apache 访问文档根目录之外的文件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5570085/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Accessing files outside the document root with Apache
提问by diggersworld
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?
我试过符号链接,但可能做错了……有什么想法吗?
采纳答案by Pekka
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.
打开。