This seems like a very simple question, but I've only found complicated answers. I've got a Zend Framework application that requires users to login. The loginAction()
and logoutAction()
are defined in AuthController
. I want to allow users to login via http://www.example.com/login rather than http://www.example.com/auth/login.
I know there are numerous ways of doing this, the 3 I've considered are:
- .htaccess rewrite
- Creating a LoginController and redirecting the indexAction() to auth/login
- Defining my own routes using Zend_Controller_Router_Rewrite.
I'd rather keep it out of #1 if possible. #2 is easy enough to understand, although it seems like a hack. It also could clutter the code with a bunch of 5-line "Controller" classes. I think #3 is the way to go but I don't fully understand how to use it effectively. I have tried Using Zend_Config with the RewriteRouter although I only defined the login route so every link became '/login' (I think I was missing a default route). I did this in my Bootstrap.php, I'm not sure if that was correct.
Is there a simple approach I'm missing? Am I using #3 incorrectly? Are there tutorials for this that I should read? (I've looked at the Zend documentation which is good but often I find myself asking, 'Where should this code go: in a controller, model, bootstrap, other?')
See Question&Answers more detail:os