doob0526 2019-03-11 06:01
浏览 90

将默认控制器更改为新控制器时页面上出现404错误

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';
  • 写回答

1条回答 默认 最新

  • doudie2693 2019-03-11 06:29
    关注

    You need to set baseurl in config file

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

    Then change default controller

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

报告相同问题?

悬赏问题

  • ¥15 微信小程序协议怎么写
  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看