In my app i record all page views in the database, something like this in AppController:
$this->Link->save(array(
'controller' => $this->request->params['controller'],
'action' => $this->request->params['action'],
'var1' => $this->request->params['pass'][0],
'var2' => $this->request->params['pass'][1]
));
which works fine, but some of the URLs people (or bots) type in are 404s. How can i check to see if these links are real or not.
Lots of requests i get are from previous websites on the same domain, requests to /images etc that Cake thinks is a controller.
I don’t mind if the check happens before entering into the database or after being retrieved from the database in a view.
Thanks!
Haven’t tried this myself, but you can try calling
Router::parse()You provide the full URL, and the return value will be cake’s route array where you can see the values of controller, action etc.