Setting controller paths in Codeigniter directories

Asked

Viewed 901 times

0

I have many controllers in my project, with this I divide the controllers into folders, website in the site folder, admin in the admin folder (within controllers).

But I can’t access the controllers without having to put the folder base in the URL, example:

I want to access it like this: http://localhost/gabriel/projeto/sobre
But that’s the only way I can do it: http://localhost/gabriel/projeto/site/sobre

File 'Routes' is like this:

$route['default_controller'] = "site/index/site";
$route['404_override'] = '';
$route['admin'] = "admin/login";

I’ve tried to modify the htaccess but I didn’t get any results. I put one more line in the file 'Routes':

$route['(:any)'] = "site/$1";

But by placing this line it conflicts with the Admin route and can receive only one parameter in the URL.

How can I solve this problem?

1 answer

1


Try to do it this way, using the (.*) as a capture group, getting the whole URL:

$route['admin/(.*)'] = "admin/$1";
$route['(.*)'] = "site/$1";
  • Thank you very much solved my problem. I was just trying with (:any), not with the *

  • @user3092202 If this answer solved your problem, Voce can mark it as certain.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.