thinkphp5新增模块使用pathinfo方式报错404,比如:
需要检查:
1、nginx是否启用了pathinfo支持。
location / {
if (!-e $request_filename){
rewrite ^(.*)$ /index.php?s=$1 last; break;
}
}
2、控制器文件名首字母是否大写
比如Index.php的I需要大写:api\controller\Index.php
3、检查控制器代码命名空间
规则:namespace app\模块名\controller;
比如api模块:namespace app\api\controller;
4、设置了路由
比如route\route.php文件:
添加Route::get('api/hello', 'api/index/hello');
那么访问会404:
http://host/api/index/hello
只能访问
http://host/api/hello