3

当我尝试从 到 路由时,我很localhost/admin困惑localhost/index.php/admin

localhost/index.php/admin- 这个链接工作正常。

我努力了:

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

localhost/index.php/front当我打开localhost它时工作正常显示无法正常工作的首页。

我在这个例子中使用了 CodeIgniter HMVC。

我添加了额外的代码,因为它不允许我发布问题。

4

1 回答 1

2

因为您需要index.php在您的网址中删除

转到config/config.php

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

.htaccess - 放置在应用程序文件夹之外。

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

routes.php中

删除这个$route['admin'] = 'index.php/admin';

于 2016-03-11T15:18:49.500 回答