apache – 禁止访问一些静态文件

我很难与.htaccess指令。 我正在尝试Codeigniter框架的URL重写。

在生产服务器上一切正常,但我无法正确设置自己的testing服务器。

testing服务器:

url重写很好,PHP文件按预期呈现,但通过HTML(CSS,JS,IMG)包括的所有文件不显示,因为它们不可访问,由于:

403 Forbidden You don't have permission to access /path/to/file/plugins-min.css on this server. 

这里是我的.htaccess文件:

 RewriteEngine On # Do not enable rewriting for files or directories that exist RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d # For requests that are not actual files or directories, # Rewrite to index.php/URL RewriteRule ^(.*)$ index.php/$1 [PT,L] 

这是我的文档文件夹的apache2configuration:

 <Directory /document/folder/> Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec AllowOverride All Order deny,allow Allow from all </Directory> 

当我把AllowOverride设置为None即不重写URL正确显示静态文件。

当通过脚本上载图像时,即使它们具有与其他文件不相同的权限/所有者/组,也会显示在页面上。

网站上的所有内容都拥有相同的权限和所有者。

我希望我的问题已经够清楚了,我正在寻找一种方法使一切按预期工作。

我认为我的apacheconfiguration有一些防止“ 包含的Html ”文件可以访问的Apache的错误日志说:

 [Wed Aug 17 22:29:24 2011] [error] [client <MY IP>] client denied by server configuration: /var/www/site.com/application/assets/js/admin.js, referer: http://<MY IP>/site.com/page/edit/ 

提前致谢

当使用AllowOverride All在您工作的上方的其他目录中查找.htaccess文件时,这非常常见,这会影响您的configuration。 根据评论post发布这个答案来收集赏金。 下面是一个示例find命令:

findDocumentRoot -name .htacccess -print

将打印任何其他.htaccess文件。

find所有.htaccess文件:

 find /var/www/ -name .htaccess 

作为一个临时的改变:

 Order deny,allow Allow from all 

至:

 Order allow,deny Allow from all 

确保以前没有处理过Deny规则。

将以下规则添加到Apacheconfiguration部分中:

 Allow from 127.0.0.1 Allow from localhost