使用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?

我嘗試過符號鏈接,但可能做錯了......任何想法?

1 个解决方案

#1


14  

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.

打開。


注意!

本站翻译的文章,版权归属于本站,未经许可禁止转摘,转摘请注明本文地址:https://www.itdaan.com/blog/2011/04/06/72580d1d1f868bb11151bb6259885376.html



 
粤ICP备14056181号  © 2014-2021 ITdaan.com