我的项目名称是admin-api,我的域名没有指向public文件夹,指向的是项目文件夹的上级文件夹,我访问
http://pachong.test/admin-api/public
这个域名可以访问到laravel的默认首页。
我添加了一个product-temp的api接口,我访问这个域名:
http://pachong.test/admin-api/public/api/product-temp
提示我:
No input file specified.
我的地址写错了么?怎么访问我的接口?
我拿get路由试还是不行:
Route::get('/hello', function (){
return response()->json(['hello'=>'world']);
});
访问
http://pachong.test/admin-api/public/api/hello
还是没反应
首先不理解为什么要这样,业务需求?
正常情况下 nginx vhost 设置到 pulibc 目录下通过
http://pachong.test/admin-api/api/hello
可以正常访问,是因为设置了 rewrite但是你现在没有把目录设置到 public 下,所以你通过
http://pachong.test/admin-api/public/api/hello
肯定是访问不到的,因为 rewrite 没有生效。好了,问题原因找到了,解决办法其实比较清晰了,自己多尝试下。