覆盖子文件夹中的htaccess文件

时间:2014-06-04 19:52:19

标签: php .htaccess codeigniter

我正在使用Codeigniter,我已将Application文件夹中的资源(CSS,JS,Images等)分离到如下文件夹:root / resources。 CodeIgniter在根文件夹中有典型的htaccess文件,内容为:

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|images|robots\.txt|css|docs|js|system)
RewriteRule ^(.*)$ /index.php?/$1 [L]

如果我想允许资源文件存在于应用程序文件夹内的子文件夹中,如下所示:/ application / plugins / some_plugin_name / resources。我将在上面的资源文件夹中的htaccess文件中放入哪些内容,这些文件允许我访问CSS,JS和其他资源文件,如图像等?

这也与未来的插件有关,因此“some_plugin_name”文件夹可以是任何内容。

2 个答案:

答案 0 :(得分:1)

你只需要这个:

RewriteEngine On

通过打开子文件夹中的重写引擎,其规则(无)将优先于父目录中的任何规则。

答案 1 :(得分:1)

Jon Lin很接近,但还有一个额外的规则可以添加到它上面。这是在资源文件夹中工作的完整htaccess文件。您可能希望将其添加到资源文件夹下的任何文件夹中(但我可能在那里错了):

RewriteEngine On
allow from all

我发布自己答案的原因是因为它真实地花了我30分钟才找到答案。