0

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

Community
  • 1
  • 1
bosami
  • 123
  • 2
  • 11

3 Answers3

4

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.

jtavares
  • 449
  • 2
  • 9
  • 3
    maybe it has something to do with case sensitive controller names. try user lowercase on the routes definition. $route['administration/([a-z])'] $route['administration'] – jtavares Oct 31 '12 at 12:38
2

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!

user199425
  • 37
  • 6
0

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";
Pastor Bones
  • 7,183
  • 3
  • 36
  • 56