php.htaccesscodeignitercontrollerroutes

Set route in different directories Codeigniter


Divided controllers into folders, site in site folder, admin in admin folder (inside controllers).

But I can not access the controllers without putting the base of the same folder url, example:

I want to access like this: http://localhost/gabriel/projeto/about

But just so I can: http://localhost/gabriel/projeto/site/about

File 'htaccess' this so:

RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]

'base_url' this so:

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

File 'routes' this so:

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

Already tried modifying the .htaccess but no result. Inserting another line in the file 'routes':

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

But putting that line it conflicts with the route ends and the Admin can receive only one parameter in Url.

How can I solve this problem? make dynamic route...


Solution

  • I'm not 100% sure this is what you're asking, but try setting the base_url in the config/config.php file

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

    or set to whatever you want your site root to be