简体   繁体   中英

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM