dqtdz08206 2014-07-19 18:55
浏览 45
已采纳

Codeigniter URI重映射中的404错误

I get 404 error on remapping codeigniter, here is my scenario:

1-I have a controller: USER 2-When my user has logged in, it will redirected to USER/DASHBOARD but I don't have any function by name DASHBOARD in USER controller, I gave it an specific controller by name DASHBOARD but when I go to USER/DASHBOARD it gaves me 404 error...

Here is what I've done up to now:

1- my root .htaccess file:

RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
RewriteCond $1 !^(index\.php|images|css|robots\.txt)

2- my config.php changes:

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

3- my routes.php changes:

$route['user']="user";
$route['user/dashboard']="dashboard";

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

4- I have index() function in DASHBOARD controller which gives me the output text as below:

class Dashboard extends CI_Controller {

    public function index(){
        echo 'tst';
    }
}

Your help is appreciated :)

  • 写回答

1条回答 默认 最新

  • drhzn3911 2014-07-20 14:49
    关注

    Make this change to routes.php

    $route['default_controller'] = "main";
    $route['404_override'] = "";
    //reserved routes must be first
    
    $route['user/dashboard'] = "dashboard";
    //get rid of the user route, what does it do?
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 Python输入字符串转化为列表排序具体见图,严格按照输入
  • ¥20 XP系统在重新启动后进不去桌面,一直黑屏。
  • ¥15 opencv图像处理,需要四个处理结果图
  • ¥15 无线移动边缘计算系统中的系统模型
  • ¥15 深度学习中的画图问题
  • ¥15 java报错:使用mybatis plus查询一个只返回一条数据的sql,却报错返回了1000多条
  • ¥15 Python报错怎么解决
  • ¥15 simulink如何调用DLL文件
  • ¥15 关于用pyqt6的项目开发该怎么把前段后端和业务层分离
  • ¥30 线性代数的问题,我真的忘了线代的知识了