CI如何在使用控制器或转到真实文件夹之间进行利用?

时间:2013-09-09 09:45:57

标签: php codeigniter

CI如何在使用控制器或转到真实文件夹之间进行利用?

如果我有网址:http://localhost/sencha/touch/

我有一个具有相同名称的控制器方法和文件夹(但其中没有索引文件)。我的Apache服务器会给我文件夹的目录列表,而不是转到控制器方法(这会给我正确的索引文件)。

更多上下文:

我有一个codeIgniter应用程序,我有一个sencha Touch应用程序,一个Ext JS应用程序,一些午睡测试。

文件夹结构如下:

-application
   -config
   -controller
     -sencha.php
         methods: 
            touch()
            touch-siesta()
            ext()
            ext-siesta()
     -some_other_controllers...
   -model
   -view
      -template
      -some_other_views....
   -... other CI folders ...
-css
-js
-sencha
   -touch
       app            -> with the sencha mvc structure
   -touch-siesta      -> with the siesta stuff
   -ext
       app            -> with the sencha mvc structure
   -ext-siesta        -> with the siesta stuff
-system
-index.php

以下网址都给我目录列表而不是使用控制器方法。

http://localhost/sencha/touch/
http://localhost/sencha/touch-siesta/
http://localhost/sencha/ext/
http://localhost/sencha/ext-siesta/

更新

我的重写条件中有这些行:

RewriteCond %{REQUEST_FILENAME} !-f
#RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?/$1 [L]

我注释掉了我检查它是否是有效目录的行。

1 个答案:

答案 0 :(得分:2)

.htaccess规则将在服务器的其他请求之前首先处理,AFAIK CI尚未处理,所以,您可以做的是以下任一项:

  1. 不要使用Mod_rewrite
  2. 编辑Mod_rewrite规则,例如:

    RewriteRule /touch/(.*)$  /index.php/touch/$1
    

    但这仅适用于特定要求,效率不高。

  3. 避免文件夹与控制器之间发生名称冲突。