[Solved] Override The Login Url

Hello there,

I’ve a small trouble with the login url and path urlformat.

My application is deployed on different servers, sometimes in a subdir. When an user tries to go on a protected page, he must be redirected to the site/login page. But I’ve mistakes because if he tryes to go on http://mydomain.tld/subdir/index.php/controller/action/, the rewriting gives http://mydomain.tld/subdir/index.php/controller/action/site/login. And if I use /site/login/, I loose the /subdir/.

And I’ve the same trouble with the errorAction.

Is there any way to solve it dynamically (without having a config file for each server) ?

Sound like issue with path-format. so you need to modify urlManager array.





or try -

// application components



                  'loginUrl' => array('site/login'),



I actually have:

'components' => array(

        'user' => array(

            'allowAutoLogin' => true,

            'loginUrl' => 'site/login',










        'errorHandler' => array(

            'errorAction' => 'site/error',


It works well if I tryed to access http://mydomain.tld/subdir/index.php/controller but fails if I’ve a final slash or anything after the controller.

I’m sure I’ve a mistake somewhere, but can’t understand where neither wich

Do you have baseUrl set in your config? You can set this value differently depending on the server.

this should resolve it

'loginUrl' => array('site/login'), // try wrapping it in array 


I knew there was a simple way, but I didn’t think trying this. Works perfectly !

Thanks a lot.

@Rohit Suthar : sorry, I didn’t noticed you used array too, I didn’t have my eyes opened yesterday :)