简体   繁体   English

Codeigniter URI重新映射中出现404错误

[英]404 error in Codeigniter URI remapping

I get 404 error on remapping codeigniter, here is my scenario: 我在重新映射codeigniter时遇到404错误,这是我的情况:

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... 1-我有一个控制器: USER 2-当我的用户登录后,它将重定向到USER/DASHBOARD但是我在USER控制器中没有名称为DASHBOARD功能,我给它指定了一个特定的控制器,名称为DASHBOARD但是当我转到USER/DASHBOARD它给了我404错误...

Here is what I've done up to now: 这是我到目前为止所做的:

1- my root .htaccess file: 1-我的根.htaccess文件:

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: 2-我的config.php更改:

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

3- my routes.php changes: 3-我的routes.php更改:

$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: 4-我在DASHBOARD控制器中具有index()函数,该函数给我以下输出文本:

class Dashboard extends CI_Controller {

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

Your help is appreciated :) 感谢您的帮助:)

Make this change to routes.php 更改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?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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