当我将welcome设置为默认控制器时,路由不起作用,默认控制器显示错误404,然后使用欢迎控制器定义的所有路由都工作但我的其他路由和url不起作用。
$route['default_controller'] = "welcome";
$route['testRoute'] = 'welcome/test';
$route['testRoute/(:num)'] = 'welcome/test/$i';
以上所有路线仅使用欢迎控制器。
$route['default_controller'] = "login";
$route['loginMe'] = 'login/loginMe';
$route['logout'] = 'user/logout';
显示所有控制器和功能的错误404.
答案 0 :(得分:0)
如果你把index.php放在域之后就行了。
http://www.example.com/index.php/login/
您应该通过替换config和.htaccess
从url中删除index.php替换config.php
$config['index_page'] = 'index.php';
通过
$config['index_page'] = '';
的.htaccess
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$0 [L]
答案 1 :(得分:0)
这对我有用:
$config['enable_query_strings'] = FALSE;
$config['uri_protocol'] = 'AUTO';
Use $config['index_page'] = '';
$config['base_url'] = 'http://localhost/code';
最后使用以下htaccess文件:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /code/index.php/$1 [L]
</IfModule>
注意:请记住在htaccess文件中编辑index.php的路径。希望这对您有用
答案 2 :(得分:-1)
正确配置.htaccess文件