Thursday, May 15, 2014

Re: Redirect all webpages under webroot to login page

I might also suggest change the DocumentRoot of your application to app/webroot, since you probably shouldn't be accessing the controllers directory directly (unless it was just an example).

On Thursday, 15 May 2014 18:38:40 UTC+10, Sam wrote:

I am using cakephp 2.4.5. I would like to redirect all users who have not logged in to a login page. I basically followed the instructions here http://miftyisbored.com/a-complete-login-and-authentication-application-tutorial-for-cakephp-2-3/

In summary, the important part is the following code to AppController.php

public $components = array('Session',                              'Auth' => array(                                  'loginRedirect' => array('controller' => 'users', 'action' => 'index'),                                  'logoutRedirect' => array('controller' => 'users', 'action' => 'login'),                                  'authError' => 'You must be logged in to view this page.',                                  'loginError' => 'Invalid Username or Password entered, please try again.'                                      ));

Any websites with this URL format http://localhost/cakephp245/controllers/XXX will be re-directed to the login page. However, websites that are located inside webroot with URL that looks like thishttp://localhost/cakephp245/app/webroot/XXX will not be re-directed to the login page.

How can I force websites located inside app/webroot folder to be re-directed to the login page?

Thank you very much.

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

No comments: