如果存在codeigniter项目,如何通过浏览器访问文件夹?

时间:2012-05-22 23:23:24

标签: php codeigniter vps

我有codeigniter项目让我们说example.com。在我服务器上的public_html文件夹中,我创建了一个名为test的文件夹,我希望能够通过web访问某些文件,使用example.com/test/somefile.php

由于我在同一个public_html目录中也有一个codeigniter项目,所以当我尝试使用example.com/test/somefile.php时,我总是得到一个找不到codeigniter页面的错误。

我怎样才能告诉我的服务器或codeigniter项目文件夹“test”不是codeigniter应用程序的一部分?

1 个答案:

答案 0 :(得分:3)

.htaccess根目录public_html中,您可能有类似的内容通过index.php路由所有内容:

CI用户指南中的示例:http://codeigniter.com/user_guide/general/urls.html

RewriteEngine on
# If the path doesn't start with one of these...
RewriteCond $1 !^(index\.php|images|robots\.txt)
# ...send the request to index.php/REQUEST
RewriteRule ^(.*)$ /index.php/$1 [L]

只需将“test”添加到管道分隔组,或者您需要做什么来允许使用您的配置访问目录:

RewriteCond $1 !^(index\.php|test|images|robots\.txt)
#                            ^^^^

如果没有此CI在URL中需要index.php - 实际上没有办法让您的Codeigniter应用程序本身重定向,重写URL或阻止访问/test目录,它通常都是通过{{ {1}}档案。