TP5路由如何禁止get请求

浏览:936 发布日期:2019/04/01 分类:求助交流 关键字: 路由 get
网站是查询站点,单独写了页面,/cha/
但是发现这2天有人一直get请求疯狂查询,我把路由设置为post后,可以把禁止,但是原来的/cha/页面无法打开了,有没有办法只允许post请求,但是页面可以正常打开的。
路由规则:Route::post('/cha/', 'index/cha/index');代码:        if(request()->isPost()) {

            $param = input('post.');

            $result = $this->validate($param, 'User');
            if(true !== $result){
                $this->redirect('/cha/'); // 重定向
            }

            $user = new GetUserInfo();
            $res = $user->getTaoBaoFromApi($param);
最佳答案
评论() 相关
后面还有条评论,点击查看>>