bosami
bosami

Reputation: 123

routes.php and controllers (codeigniter)

I have two controllers 1- site 2- management

the first controllers(Site) is work successfuly the second controllers(Managemnt) is not work.

I don't know what is the errror

I change the routes.php but still doesn't work(managment)

$route['default_controller'] = "site";
$route['(:any)'] = "site/$1";
$route['Administration'] = "Administration/index";
$route['Administration/([a-z])'] = 'Administration/$1';

this links work:

example.com/hotel/12312

example.com/contact

example.com/city/newyork

example.com/Administration

but this links doesn't works:

example.com/Administration/hotels

example.com/Administration/add_new

example.com/Administration/cities

where is the problem pls because I tired to solve this problem

thaks

Upvotes: 0

Views: 2060

Answers (3)

user199425
user199425

Reputation: 37

I had same problem & I get this working:

$route['default_controller'] = "welcome";
$route['([a-z-A-Z1-9_]+)'] = "site";
$route['management']="management";
$route['404_override'] = '';

it may help you!

Upvotes: 2

jtavares
jtavares

Reputation: 449

It has to do with the order in witch you are giving route directives. Code igniter routes requests from top to bottom, so if you want your $route['Administration'] to precede $route['(:any)'] you have to set it first.

$route['default_controller'] = "site";
$route['Administration/([a-z])'] = 'Administration/$1';
$route['Administration'] = "Administration/index";
$route['(:any)'] = "site/$1";

I would allways sugest putting (:any) routes at the end so they don't overwrite more specific routes.

Upvotes: 4

Pastor Bones
Pastor Bones

Reputation: 7351

I'm not familiar with Codeigniter routing, but to me looks like everything is matching $route['(:any)'] = "site/$1"; before it ever reaches your Administration routes. Try moving it below everything else...you might also have to switch your Administration routes for the ([a-z]) to match

$route['default_controller'] = "site";
$route['Administration/([a-z])'] = 'Administration/$1';
$route['Administration'] = "Administration/index";
$route['(:any)'] = "site/$1";

Upvotes: 0

Related Questions