我正在开发有关Codeigniter 3的项目,但是我遇到了路由问题。
$route['forgot-password'] = "Auth/forgot_password";
当我请求URL显示错误时,错误在下面给出
http://localhost/myproject/forgot-password/404
在Codeigniter 2上工作正常,但在Codeigniter 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]