createUrl return getUrl (current page url ) ??? on MassVhost

Hi all

I have a very strange and kind of bloking behavior

While deploying our site on a MassVhost

if on Url : my.server.com/whatever

a simple Yii:app()->createUrl(’/’) returns my.server.com/whatever instead of server.com/

the strange thing about this is that it works fine locally

any idea is welcome ?

below snippet from our VHost Config maybe can help:


 VirtualDocumentRoot /pathto/www/%0


RewriteEngine on

 RewriteBase /%0

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

RewriteCond $1 !^(index\.php|assets|robots\.txt)

RewriteRule ^(.*)$ /index.php/$1 [PT,L,QSA]

That’s not how you link to the homepage.

What’s happening is that the slash is being stripped off the route, so the route becomes “” which createUrl() turns into the route of the current controller

Instead:





Yii::app()->createUrl("/site/index");



and add a URL rule in your main config:




"urlManager" => array(

    "rules" => array(

        "/" => "site/index"

    )

),



Thanks for the explanation.