【发布时间】:2016-05-31 16:59:10
【问题描述】:
在我的项目中,我创建了操作 ajax 请求的 AjaxController。 我想输入 ajax 使用的 url 的用户得到 404 错误。 在 AjaxController.php 我有:
public function initialize() {
if (!$this->request->isAjax()) {
return $this->response->redirect('error/show404');
}
}
(当然我有带 show404Action 的 ErrorController)
它不起作用。当我在浏览器中输入 example.com/ajax 时,我从 AjaxController 中的 IndexAction 获取内容。如何修复?
【问题讨论】:
-
也许您可以为此使用中间件?