Codeigniter“未指定输入文件”&实时出现“404 未找到页面”错误
我有一个 我在 codeigniter 2.0.1 上构建的网站(我自己的个人网站)。我使用 WAMP 在本地构建了此应用程序,它可以 100% 正常工作(本地)。我将其上传到我的实时服务器,但不断收到“404 页面未找到”错误。这个错误是通过我的 Home->Error 方法来自 codeigniter 的,而不是服务器,所以 codeigniter 肯定可以工作。
这是我的路线配置。如果我将 404_override 更改为“Home”。它按应有的方式加载我的家庭控制器,但是当我转到任何页面时,我都会收到 404 页面未找到的信息。
$route['default_controller'] = 'Home';
$route['404_override'] = 'Home/Error';
我怀疑这可能与我的 .htaccess & 有关。代码点火器配置。
// 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 页面未找到,但为什么?
- 现有控制器上的 codeigniter 404
- http://codeigniter.com/forums/viewthread/60469/#297477
- http://codeigniter.com/wiki/Godaddy_Installaton_Tips
- 在许多其他方面,
我确信这与 htaccess 和 mod_rewrite 有关,有什么想法吗?
Update
If I change the the
$route['404_override'] = 'Home/Error'
to any of my controllers, they show and work as expected, but for some reason, its always throwing a 404 page.如果我转到:/index.php/home
- 我收到错误未指定输入文件。
I have a website I built on codeiginiter 2.0.1 (My own personal site). I built this application locally using WAMP and it works 100% as it should (Locally). I uploaded this to my live server and I keep getting "404 page not found" error. This error is coming from codeigniter through my Home->Error method, not the server, so code igniter is definitely working.
Here is my routes config. If I change the 404_override to 'Home'. It loads my home controller as it should, but when I go to ANY page I get the 404 page not found.
$route['default_controller'] = 'Home';
$route['404_override'] = 'Home/Error';
I suspect this may have something to do with my .htaccess & Codeigniter config.
// 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';
My .htaccess
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?$1 [L]
I tried so many links through SO & Google to fix this, the ones I tried repetitively are below.
- 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
- Amongst many others
I'm sure this has goto do with the htaccess and mod_rewrite, Any Ideas?
Update
If I change the the
$route['404_override'] = 'Home/Error'
to any of my controllers, they show and work as expected, but for some reason, its always throwing a 404 page.If I go to: /index.php/home
- I get the error No input file specified.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
第一个控制器名称应为小写,例如:
$route['default_controller'] = 'home';
那么你可以将index_page留空:
$config['index_page'] = '';
最后在 .htaccess 中应该与基本路径目录中的 index.php 并排,您可以更改最后一行,例如:< br>
RewriteEngine 开启
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /home/index.php?$1 [L]
希望能解决
first controllers name should be in lowercase like:
$route['default_controller'] = 'home';
then you might leave in blank the index_page:
$config['index_page'] = '';
finally in .htaccess should be alongside index.php in the base path directory, you might change the last line like:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /home/index.php?$1 [L]
hope it solve
发现问题了..
确保您的控制器文件名是小写。
controllers/Home.php
不正确,这引发了 404 页面未找到错误。controllers/home.php
是正确的。Found the problem..
Make sure your controller filenames are lowercase.
controllers/Home.php
Is incorrect, This was throwing the 404 page not found error.controllers/home.php
Is Correct.