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

3 Answers 3

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.

Sign up to request clarification or add additional context in comments.

1 Comment

maybe it has something to do with case sensitive controller names. try user lowercase on the routes definition. $route['administration/([a-z])'] $route['administration']
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!

Comments

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";

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.