php 404 Page Not Found 未找到您请求的页面。代码点火器
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 
原文地址: http://stackoverflow.com/questions/14591581/
Warning: these are provided under cc-by-sa 4.0 license.  You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
404 Page Not Found The page you requested was not found. Code igniter
提问by mynameisjohn
i have developed a web app on code igniter .. this is the first time i am working on code-igniter .. after developing a web application on my localhost .so i decided to put my code-igniter web app on the temporary free server.. so i uploaded my site on this site 1freehosting... and then i imported my database .. after that i have changed the settings of database in database.php file .. and also i changed the base url in config.php file ..as this is my domain name http://hello.hostingsiteforfree.com/... so i changed it to this url .. but then i am getting a following error ... i dont know what is going wrong ..i have searched a lot but nothing helps.. and also i am forgot to mention that my .htaccess file is empty ..means there is not a single line in it
我已经在代码点火器上开发了一个网络应用程序..这是我第一次使用代码点火器..在我的本地主机上开发了一个网络应用程序之后.所以我决定将我的代码点火器网络应用程序放在临时免费服务器上.. 所以我将我的网站上传到这个站点 1freehosting... 然后我导入了我的数据库 .. 之后我更改了 database.php 文件中数据库的设置.. 并且我还更改了 config.php 文件中的基本 url ..因为这是我的域名http://hello.hostingsiteforfree.com/... 所以我把它改成了这个 url .. 但后来我收到了以下错误......我不知道出了什么问题..我已经搜索了很多但没有任何帮助..而且我忘了提到我的 .htaccess 文件是空的..意味着它没有一行
this is the error i am getting
这是我得到的错误
404 Page Not Found
The page you requested was not found.
routes.php
路由文件
    <?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
 $route['default_controller'] = "loginController";
$route['404_override'] = '';
 /* Location: ./application/config/routes.php */
my controller
我的控制器
   <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class LoginController extends CI_Controller {
类 LoginController 扩展 CI_Controller {
 function index(){
    $new['main_content'] = 'loginView';
    $this->load->view('loginTemplate/template', $new); 
}
function verifyUser(){
    //getting parameters from view 
    $data = array(
            'username' => $this->input->post('username'),
            'password' => $this->input->post('password')
    );
    $this->load->model('loginModel'); 
    $query = $this->loginModel->validate($data);
          if ($query){             //if the user c validated
        //data variable is created becx we want to put username in session
            $data = array(
                'username' => $this->input->post('username'),
                 'is_logged_in' => true 
            );
           $this->session->set_userdata($data);
         redirect('sessionController/dashboard_area');
    }
    else
     {
        $this->index();
    }
}
function logout()
{
    $this->session->sess_destroy();
    $this->index();
}
}
?>
config file
配置文件
   $config['base_url']  = 'http://hello.hostingsiteforfree.com/';
   $config['index_page'] = 'index.php';
采纳答案by tomexsans
Since you do not have any .htaccess to edit you url you must add an index.phpwhen calling a controller like
由于您没有任何 .htaccess 来编辑您的网址,因此您必须index.php在调用控制器时添加一个
http://hello.hostingsiteforfree.com/index.php/loginController
http://hello.hostingsiteforfree.com/index.php/loginController
I tried accessing it via the url above and it works, but the database connection is not set up properly
我尝试通过上面的 url 访问它,它可以工作,但数据库连接设置不正确
in your config file where there is $config['index_page'] = ''if it is blank add an index.phpto it
在你的配置文件,其中有$config['index_page'] = '',如果它是空白加入一个index.php吧
Check to see it works
检查它是否有效
回答by jsanc623
Look at your application/routes.phpand make sure that your $route['default_controller']is correctly set to your default controller. As follows, this is my routes.php:
查看您的application/routes.php并确保您$route['default_controller']已正确设置为默认控制器。如下,这是我的routes.php:
$route['default_controller'] = "home";
$route['404_override'] = '';
Also, make sure that your default controller (in my case, its application/controllers/home_controller.phpand within it is class Home extends CI_Controller {...}
另外,请确保您的默认控制器(在我的情况下,它application/controllers/home_controller.php和它内部是class Home extends CI_Controller {...}
--
——
If that doesn't work, make sure your default controller is correctly calling your default view and loading it as such:
如果这不起作用,请确保您的默认控制器正确调用您的默认视图并按如下方式加载它:
$this->load->view('home_view', $data);
--
——
If THAT doesn't work, then take a look at your application/config/config.phpand make sure that the following are correctly set as follows IF you want to get rid of your index.phpin the url (for clean urls):
如果这不起作用,请查看您的application/config/config.php并确保以下内容正确设置如下,如果您想删除您index.php的网址(对于干净的网址):
$config['index_page'] = ''; $config['uri_protocol'] = "AUTO";
$config['index_page'] = ''; $config['uri_protocol'] = "AUTO";
and if you're going for clean urls, do post your .htaccess (which should follow something like this: http://www.farinspace.com/codeigniter-htaccess-file/) so we can look at it in further detail and try to fix it if none of the above fix it.
如果您想要干净的网址,请发布您的 .htaccess(应该遵循以下内容:http: //www.farinspace.com/codeigniter-htaccess-file/),以便我们可以更详细地查看它并如果以上都没有修复它,请尝试修复它。
回答by user2001057
Have you removed index.php with .htaccess? If not then put it in the end.
你用 .htaccess 删除了 index.php 吗?如果没有,那么把它放在最后。

