如何将api.example.com路由到example.com/api,以便我可以
api.example.com/v1/users
比使用
example.com/api/v1/users.
我正在使用Nginx,谢谢。
Symfony3 + Vuejs Nginxconfiguration
使用variables时,在Nginx上重写URI不起作用
如何在yii2中获得像“post / 100”这样的干净url
通过VMWARE路由VPN(MacOSx – Windows)
使用ip route add将组播路由添加到多个设备
如何configurationlinux路由,将数据包从一个接口发送出去,通过一个网桥,并进入同一个盒子的另一个接口
Nginx的重写规则为AngularJS和html5mode启用
在linux中使用c ++检测连接的接口
确保这两个步骤到位。
检查你的Nginx配置文件/etc/Nginx/conf.d/example.conf并在server_name包含这个域,如下所示:
server_name example.com api.example.com;
检查您在routes/api.PHP文件中是否有路由设置。 使用子域组是可选的,但请确保您拥有正确的路由。
使用域组的示例:
Route :: group(['domain'=>'api.example.com'],function(){
Route :: get('/ v1 / users',['as'=>'api.users.index','uses'=>'UserController @ index']);
}
不使用域组的示例,并允许两个URL指向相同的控制器(确保按照'as'定义自己的路由名称)。
Route :: get('/ v1 / users',['as'=>'api.users.index','uses'=>'UserController @ index']);
Route :: get('/ api / v1 / users',['as'=>'users.index','uses'=>'UserController @ index']);
更新 :
请参阅官方Laravel 5.3有关使用子域路由的文档https://laravel.com/docs/5.3/routing#route-group-sub-domain-routing
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。