yiiyii-url-manageryii-modules

Same URL whether called from module or not


If I use Yii::app()->createUrl('user/login') i will get the result as '/user/login'

But I will use Yii::app()->createUrl('user/login') inside a module i will get '/module/user/login'

Is there any way so that I can '/user/login' irrespective of from where createUrl is called?

I am using a common function which returns the url.


Solution

  • Yii::app()->createUrl('//user/login')
    

    will work for you. The // refers to the application root. To access controllers inside other modules you can use //module/controller/action