DocumentRoot的背后MOD-重写加载文件 [英] Mod-Rewrite loading files behind the DocumentRoot
问题描述
我用的.htaccess
和的mod_rewrite
指向驻留在DocumentRoot的隐藏文件。我的文件夹结构如下所示:
I'm using .htaccess
and mod_rewrite
to point to files that reside behind the DocumentRoot. My folder structure looks like this:
home/
webroot/
other_files/
我有一个的.htaccess
文件根目录包含以下内容:
I have a .htaccess
file in webroot with the following content:
RewriteEngine on
RewriteRule ^(.*)$ /home/other_files/$1
如果我尝试访问 http://example.com/file.html 我收到以下错误:
If I try to access http://example.com/file.html I receive the following error:
所请求的网址/home/other_files/file.html在此服务器上找到。
The requested URL /home/other_files/file.html was not found on this server.
它甚至有可能加载位于DocumentRoot的隐藏文件?如果是的话,可以有人点我在正确的方向?
Is it even possible to load files that are behind the DocumentRoot? If so, can someone point me in the right direction?
推荐答案
我相信你需要用
<Directory "/home/other_files">
(options)
</Directory>
到Apache在你的服务器配置将能够从中起到什么。举个例子,我的DocumentRoot是/ var / WWW但本节中的默认提供网站:
to your server configuration before apache will be able to serve anything from it. For an example, my DocumentRoot is /var/www but there is this section in the default available site:
Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>
您可以再重写URL去/ DOC /,服务器会知道从哪里获取的文件。
You could then rewrite a URL to go to /doc/ and the server would know where to get the files from.
这篇关于DocumentRoot的背后MOD-重写加载文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!