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 c程序不知道为什么得不到结果
  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置