[英]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.