Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Apache htaccess:允许公众访问';公共';文件夹_Apache_.htaccess_Codeigniter - Fatal编程技术网

Apache htaccess:允许公众访问';公共';文件夹

Apache htaccess:允许公众访问';公共';文件夹,apache,.htaccess,codeigniter,Apache,.htaccess,Codeigniter,我使用的是Codeigniter 2.0.3 | Apache2.2.17 | PHP5.3.4 我想授予访问“公用”文件夹中所有文件和子文件夹的权限。我已经阅读了Codeigniter wiki上的文章,以及谷歌搜索结果的前5页,但没有发现任何有用的东西 这是文件树: - application - public - css - style.css - img - js - system - .htaccess

我使用的是Codeigniter 2.0.3 | Apache2.2.17 | PHP5.3.4

我想授予访问“公用”文件夹中所有文件和子文件夹的权限。我已经阅读了Codeigniter wiki上的文章,以及谷歌搜索结果的前5页,但没有发现任何有用的东西

这是文件树:

- application
    - public
        - css
            - style.css
        - img
        - js
- system
- .htaccess
这是我用来从URL中删除'index.php'并尝试访问文件夹的.htaccess:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /CodeIgniter_2.0.3

#Removes access to the system folder by users.
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php/$1 [L]

#Checks to see if the user is attempting to access a valid file,
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

#Enable access to the images and css folders, and the robots.txt file
RewriteCond $1 !^(index\.php|public|robots\.txt)
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
请帮忙。
谢谢

使用当前结构,您需要将最后一个
重写条件更改为:

RewriteCond $1 !^(index\.php|application\/public|robots\.txt)

由于您的
.htaccess
与您的应用程序文件夹位于同一目录中,并且您的公用文件夹位于您的应用程序文件夹中,因此您需要明确地将应用程序/公用文件夹标记为可访问。

但是,我要说的是,您的结构不是标准的。通常,您的
public
文件夹与您的应用程序和系统文件夹相邻,而不是在其中任何一个文件夹中。谢谢,刚刚在树中向上移动了“public”,它工作得很好!哪个文件夹是您的DocRoot?我假设它是公共的?
RewriteCond $1 !^(index\.php|application\/public|robots\.txt)