Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CodeIgniter routing link in routes.php

I am confused when I try to route from localhost/admin to localhost/index.php/admin

localhost/index.php/admin - this link working fine.

I have tried:

$route['admin'] = 'index.php/admin';
$route['default_controller'] = 'front';

localhost/index.php/front is working fine when I open localhost it displays front page which is not working.

I am using CodeIgniter HMVC in this example.

I added extra code as it was not allowing me to post the question.

like image 514
abhishek Avatar asked Jun 06 '26 17:06

abhishek


1 Answers

Because you need to remove index.php in your URL

Go to config/config.php

$config['base_url'] = 'http://localhost/projectname/';
$config['index_page'] = ''; # remove index.php on here

In .htaccess - place outside application folder.

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
#RewriteRule .* index.php/$0 [PT,L]
RewriteRule ^(.*)$ index.php/$1 [L,QSA]

And in routes.php

remove this $route['admin'] = 'index.php/admin';

like image 63
Abdulla Nilam Avatar answered Jun 09 '26 05:06

Abdulla Nilam



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!