2
votes

I am developing a web application with codeigniter. I have created a folder in controllers with name "Administration". Inside this folder, i have kept all my controllers pertaining to the administration panels.

Now, i want that if any user types the url as www.mywebsite.com/administration, the user should be redirected to the respective controller whatever comes as the next segment after administration. like if user types wwww.mywebsite.com/administration/login, then login controller should be executed. Well this is a pretty obvious thing.

Now what i want is, when someone types anything www.mywebsite.com/anything_else, it should be directed to some other controller by default. I am using following routes setup:

$route['default_controller'] = 'welcome';
$route['404_override'] = ''; 
$route['administration/(:any)']='administration/$1';
$route['(:any)']='fetch_pages';

Please guide.

2

2 Answers

0
votes

I'd suggest you to do another approach:

$route['default_controller'] = 'welcome';
$route['404_override'] = 'fetch_pages/index'; 

This solution makes you able to skip declaring the obvious administration route, and all other paths will be called through fetch_pages controller.

Read more about 404_override

Depending on your needs, you may want to consider running show_404() when you can't find data based on uri.

0
votes
$route['^(?!administration).*'] = "fetch_pages";
$route['administration/(:any)']='Administration/$1';

I think you have created folder with capital letter "A" in Administration