In my project I've created AjaxController which operated ajax requests. I'd like to user which enter to url used by ajax get 404 error. In AjaxController.php I have:
public function initialize() {
if (!$this->request->isAjax()) {
return $this->response->redirect('error/show404');
}
}
(Of course I have ErrorController with show404Action)
It doesn't work. When i enter to example.com/ajax in browser I get content from IndexAction in AjaxController. How to repair it?