404 Page not found. The page you requested was not found. Igniter code

I developed a web application for code igniter .. this is the first time I'm working on code ignition .. after developing a web application on my localhost.so I decided to put my application to fire code on a temporary free server .. so I downloaded my the site on this site is 1freehosting ... and then I imported my database .. after that I changed the database settings in the database.php file .. and also I changed the base url in the config.php file .. this is my http domain name : //hello.hostingsiteforfree.com/ ... so I changed it to this url .. but then I get the following error bku ... I don’t know what is going wrong .. I searched a lot, but nothing helps .. and also I forgot to mention that my .htaccess file is empty ..means there is not a single line

this is the error i get

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 {

 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();
}
}



?>

configuration file

   $config['base_url']  = 'http://hello.hostingsiteforfree.com/';
   $config['index_page'] = 'index.php';
+3
source share
3 answers

Since you do not have .htaccess to edit the URL, you must add index.php when calling the controller, for example

http://hello.hostingsiteforfree.com/index.php/loginController

I tried to access it via the url above and it works, but the database connection is not configured correctly

in your configuration file, where there is $config['index_page'] = '', if it is empty, add index.phpto it

Check if it works.

+3
source

application/routes.php , $route['default_controller'] . , .php:

$route['default_controller'] = "home";
$route['404_override'] = '';

, , ( , application/controllers/home_controller.php class Home extends CI_Controller {...}

-

, , :

$this->load->view('home_view', $data);

-

THAT , application/config/config.php , , index.php URL- ( URL-):

$config ['index_page'] = ''; $ config ['uri_protocol'] = "AUTO";

URL-, .htaccess( : http://www.farinspace.com/codeigniter-htaccess-file/), , .

+1

Have you deleted index.php with .htaccess? If not, then put it at the end.

0
source

Source: https://habr.com/ru/post/1607642/


All Articles