【问题标题】:Codeigniter "No input file specified" even after pasting a new .htacessCodeigniter“未指定输入文件”即使粘贴新的.htaccess
【发布时间】:2013-04-08 00:47:55
【问题描述】:

我正在尝试安装 codeIgniter,并且我已将所有 codeIgniter 文件复制到 http://www.mydomain.com 中名为 /backend 的文件夹中。

现在,http://www.mydomain.com/backend/index.php 显示 codeIgniter 欢迎页面。

然后我在/backend/controller 文件夹中创建了一个main.php。但是当我打开http://www.mydomain.com/backend/index.php/main 时,它会显示No input file specified

查看this question后,我将一个.htaccess文件粘贴到/backend文件夹中,内容如下。

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

但页面http://www.mydomain.com/backend/index.php/main 仍然显示No input file specified

为什么.htaccess 没有任何区别?我不明白发生了什么。

【问题讨论】:

  • 可能是你的服务器没有启用mod_rewrite,或者没有开启AllowOverrides(即启用.htaccess文件)。
  • 有了那个 .htaccess 文件,您可能希望您的 url 采用 mydomain.com/backend/main 的形式。由于它将所有对不存在文件的请求都指向 index.php,因此直接请求 index.php 没有意义
  • @MikeBrant mod_rewrite 已启用,同一个 .htaccess 文件执行其他重定向。
  • @SamDufel 网址 mydomain.com/backend/main 显示 404。
  • @blenderous - 尝试将RewriteBase 切换为/backend 或将RewriteRule 更改为^(.*)$ backend/index.php?/$1 [L]

标签: php .htaccess codeigniter


【解决方案1】:
RewriteEngine On
RewriteBase /backend
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /backend/index.php/$1 [L]

然后浏览到:

http://www.mydomain.com/backend/main

而不是:

http://www.mydomain.com/backend/index.php/main

确保您删除了 config/config.php 中的 index.php 并设置了 $config['uri_protocol'] = 'AUTO'; (try also other solutions here if still not working)

【讨论】:

    猜你喜欢
    • 2017-07-24
    • 1970-01-01
    • 1970-01-01
    • 2010-12-06
    • 2011-07-10
    • 1970-01-01
    • 1970-01-01
    • 2014-02-06
    • 1970-01-01
    相关资源
    最近更新 更多