开发者

Codeigniter routing question

I have a CI application with organized folders. I have several folders on views, controllers and models.

ie.: /controllers/frontend/, controllers/backend /views/frontend, views/backend

... etc ...

So开发者_Python百科 if i want to access the function 'login' on the frontend controller i have to go to: http://localhost/frontend/login/index

What i want is to get rid of the need of typing 'frontend', so if i type http://localhost/login/index, it would be the same as http://localhost/frontend/login/index.

Of course i dont want to add them manually to the routes file, i want it to be recognized automatically.

Thanks.


Try changing line 17 in your config.php file in application\config.

$config['base_url'] = 'http://localhost/';

Change above to below:

$config['base_url'] = 'http://localhost/frontend/';


I know you don't want to change your routing for each controller, but if this is the only one you need to do a specific routing for, you can change the default controller in the Router file inside your application/config folder to:

$route['default_controller'] = 'frontend';
$route['(:any)'] = "frontend/some_secondary_variable";

The second line is only if you need to pass variables to the controller, otherwise, omit it.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜