为什么Codeigniter 2路由工作,但在Codeignite器3上不工作


Why does Codeigniter 2 routing work but not on Codeigniter 3?

我正在开发一个关于codeigniter 3的项目,但我有一个路由问题。

$route['forgot-password'] = "Auth/forgot_password";

当我请求url时,它显示了一个错误,错误在下面给出

http://localhost/myproject/forgot-password/404

它在Codeigniter 2上工作良好,但在Codeignitr 3上不工作。

提前感谢

在代码点火器3 中

$route['forgot-password'] = "Auth/forgot_password";

更改为

$route['forgot-password/(:any)'] = "Auth/forgot_password/$1";

或者只是数字

$route['forgot-password/(:num)'] = "Auth/forgot_password/$1";

在根项目中创建文件.htaccess并附加代码

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]