Cameron
Cameron

Reputation: 28793

CakePHP Two routes at the same url

Is it possible to create two routes at the same url?

So for example:

Router::connect('/', array('controller' => 'users', 'action' => 'login'));
Router::connect('/', array('controller' => 'home', 'action' => 'index'));

The idea is that e.g. www.mywebsite.com will show the login page as its home page without any redirects to a login page or anything. Once the user logs in then they will be taken to the home page again but instead it will load the home controller index but again same URL!

How would I do this?

Upvotes: 1

Views: 467

Answers (1)

pawelmysior
pawelmysior

Reputation: 3250

Well, you definitely can't do that like that.

You could try setting / to home/index and checking whether the user is logged in in the home/index view, and display the login form if he's not. And also check for user being logged in in the controller.

That said, I really can't image why you would want to do it like that. Especially if you're using the AuthComponent.

Upvotes: 1

Related Questions