【问题标题】:Codeigniter sub-folder multiple controllersCodeigniter 子文件夹多个控制器
【发布时间】:2023-04-07 18:03:02
【问题描述】:

这是我的 htaccess 文件,它有点工作。无论我指定什么控制器,它总是会进入主页

<IfModule mod_rewrite.c>
RewriteEngine On

#Checks to see if the user is attempting to access a valid file,
#such as an image or css document, if this isn't true it sends the
#request to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
#This last condition enables access to the images and css folders, and the robots.txt file
RewriteCond $1 !^(index\.php|css|js)
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>

这是我的网址

http://automationmetrics.local/automation/

想法?

【问题讨论】:

    标签: .htaccess codeigniter


    【解决方案1】:

    当我遇到这种情况时,我通常会检查一些事情:

    • 我是否在 Apache 中启用了 mod_rewrite 模块?
    • 我是否将 $config['index_page'] 设置为空白?

    如果上述方法有效,这是我使用的那个,这对我有用:

    https://gist.github.com/petrepatrasc/6925413

    如果您仍然不走运,请尝试摆弄 $config['uri_protocol'] 参数 - 我记得我只能使用 REQUEST_URI 作为值使其在 Windows(当时使用 IIS)上工作.可能与此有关。

    【讨论】:

      【解决方案2】:

      前两个规则会在所有文件上触发,就像评论中所说的那样。所以这个:

      RewriteCond $1 !^(index\.php|css|js)
      

      似乎是多余的,删除它应该可以解决您遇到的问题。

      【讨论】:

      • 这可能应该是一个评论而不是一个答案,因为它是一个长远的目标 - 因为可能会出现许多问题并造成 OP 遇到的问题......但从问题中给出的内容来看,这个可以作为答案。
      • 删除该行解决了问题。
      猜你喜欢
      • 1970-01-01
      • 2013-09-16
      • 2012-06-24
      • 1970-01-01
      • 1970-01-01
      • 2013-12-05
      • 2015-03-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多