简体   繁体   中英

404 error on page when I change default controller to new controller

I had created login page in codeigniter and made it default controller when the application is hit but I am getting 404 page not found error when the application is hit. Please find below code of controller as main.php config and route file changes placed. My controller name is main.php and the code is as follows

<?php  
defined('BASEPATH') OR exit('No direct script access allowed');  

class Main extends CI_Controller {  
    //functions  
    function login()  
    {  
        $data['title'] = 'CodeIgniter Simple Login Form With Sessions';  
        $this->load->library('form_validation');

        $this->load->view("login", $data);  
    }  

htaccess

<IfModule authz_core_module>
    Require all denied
</IfModule>

<IfModule !authz_core_module>
    Deny from all
</IfModule>

route file

$route['default_controller'] = 'main';

config file

$config['base_url'] = '';
$config['index_page'] = 'index.php';
$config['encryption_key'] = 'xRUqKhsoZ5qV6y3kqARFJFdPqJvp7X2z';

You need to set baseurl in config file

$config['base_url'] = 'localhost/cifolder/';

Then change default controller

$route['default_controller'] = 'Main';

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM