繁体   English   中英

routes.php中的CodeIgniter路由链接

[英]CodeIgniter routing link in routes.php

当我尝试从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。

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

因为您需要删除URL中的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';

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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