【问题标题】:How to access folder via browser if codeigniter project exists?如果存在codeigniter项目,如何通过浏览器访问文件夹?
【发布时间】:2012-05-29 12:02:31
【问题描述】:

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

因为我在同一个 public_html 目录中也有一个 codeigniter 项目,所以当我尝试 example.com/test/somefile.php 时,我总是得到一个 codeigniter page not found 错误。

我如何基本上告诉我的服务器或 codeigniter 项目文件夹“test”不是 codeigniter 应用程序的一部分?

【问题讨论】:

    标签: php codeigniter vps


    【解决方案1】:

    public_html 根的.htaccess 中,您可能有类似这样的东西来通过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 目录的访问,这通常都是通过 .htaccess 文件完成的。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-06-19
      • 1970-01-01
      • 2014-04-08
      • 1970-01-01
      • 2016-07-16
      • 1970-01-01
      • 1970-01-01
      • 2013-05-22
      相关资源
      最近更新 更多