【问题标题】:Codeigniter `No Input File Specified` & `404 Page Not Found` Errors when LiveCodeigniter `No Input File Specified` & `404 Page Not Found` 实时错误
【发布时间】:2011-12-13 04:16:26
【问题描述】:

我有一个website I built on codeiginiter 2.0.1(我自己的个人网站)。我使用 WAMP 在本地构建了这个应用程序,它可以 100% 正常工作(本地)。我将此上传到我的实时服务器,但我不断收到“404 page not found”错误。这个错误来自 codeigniter 通过我的 Home->Error 方法,而不是服务器,所以 code igniter 肯定在工作。

这是我的路线配置。如果我将 404_override 更改为“Home”。它会按原样加载我的家庭控制器,但是当我转到任何页面时,我都找不到 404 页面。

$route['default_controller'] = 'Home';
$route['404_override'] = 'Home/Error';

我怀疑这可能与我的 .htaccess 和 Codeigniter 配置有关。

// Codeigniter Config.php - Note: My Hosting is with Godaddy. [CGI/FastCGI]
$config['index_page'] = 'index.php?';
// Tried Auto and All others, REQUEST_URI works fastest for me.
$config['uri_protocol'] = 'REQUEST_URI';

我的 .htaccess

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

我通过 SO 和 Google 尝试了很多链接来解决这个问题,我反复尝试的链接如下。
- CodeIgniter 404 Page Not Found, but why?
- codeigniter 404 on existing controller
- http://codeigniter.com/forums/viewthread/60469/#297477
- http://codeigniter.com/wiki/Godaddy_Installaton_Tips
- 还有很多

我确定这与 htaccess 和 mod_rewrite 有关,有什么想法吗?


更新
如果我将 $route['404_override'] = 'Home/Error' 更改为我的任何控制器,它们会按预期显示和工作,但由于某种原因,它总是抛出 404 页面。

如果我去:/index.php/home - 我收到错误 No input file specified.

【问题讨论】:

标签: php .htaccess mod-rewrite codeigniter-2 codeigniter-url


【解决方案1】:

发现问题..
确保您的控制器文件名是小写的
controllers/Home.php 不正确,这是抛出 404 page not found 错误。 controllers/home.php 是正确的。

【讨论】:

  • @chrisramon 不是先给你小写的答案吗?
【解决方案2】:

第一个控制器名称应为小写,例如:
$route['default_controller'] = 'home';

那么您可以将 index_page 留空:
$config['index_page'] = '';

最后,.htaccess 应该在基本路径目录中的 index.php 旁边,您可以将最后一行更改为:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
@ 987654325@
RewriteRule ^(.*)$ /home/index.php?$1 [L]

希望能解决

【讨论】:

  • +1 表示第一个 - 在 WAMP 上,服务器可能以不区分大小写的方式处理路径名。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-12-05
  • 1970-01-01
  • 1970-01-01
  • 2011-11-09
  • 2016-09-10
  • 1970-01-01
相关资源
最近更新 更多