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 :)
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?
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.