CakePHP controller alias

Viewed 3025

I know there are a couple of other topics about this subject, but non of them seems to fit my needs.

What I have

  • example.com/log/
  • LogsController.php

I have LogsController instead of LogController (plural) because CakePHP wants you to have controllers in plural.

But as you might know/notice, example.com/log/ will never use LogsController because of the missing 's' in the url.

Now, I want to have /log/* being redirected to /logs/*. Works perfectly fine with the following code:

Router::connect ('/log/*', array('controller'=>'logs'));

But, when I try to access example.com/log/actions/foo/bar it doesn't seem to work. So after some Googeling I found this:

Router::connect ('/log/:action/*', array('controller'=>'logs'));

Works great. But now when I'm trying to access example.com/log/ again, it says

Error: LogController could not be found.

Question So my question is, how do I set up an alias for my url so that /log/ will use LogsController instead of trying to use LogController.

I have a few more Controllers where I'd like to change this, like flight => FlightsController, profile => ProfilesController.


Have a look at this question. It is about the same subject, but slightly different. It might help you in some way.

4 Answers
Related