I want to capture parameter from url on default controller but it give ma an error 404 page not found.
routes.php
$route['default_controller'] = 'MainBrain';
$route['MainBrain/(:any)'] = "MainBrain/index/$1";
$route['404_override'] = '';
$route['translate_uri_dashes'] = FALSE;
MainBrain .php
class MainBrain extends CI_Controller {
public function __construct() {
parent::__construct();
$this->load->helper('url');
}
public function index() {
echo 'Parameter value - ' . $this->uri->segment(3);
$this->load->view('index', $data);
}
}
Now when ever I try load url
localhost:/myproject => This is loading my default controller and its view but when I try localhost:/myproject/pa8989 => This gives me 404 page not found error.
.htaccess :
RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L,QSA]
So how can I get parameter form default parameter instead of 404 error ?