How To Get Full Base Url (Http://domain.com/) ?

I know it was asked before but the common answer doesn’t work for me


var_dump(Yii::app()->getBaseUrl(true));

outputs


string(<img src='http://www.yiiframework.com/forum/public/style_emoticons/default/cool.gif' class='bbc_emoticon' alt='8)' /> "http://."

How can I get "http://domain.com/" ?

Update: I’m using it from a shell command.

It should work. It sounds like a misconfiguration of the server. Is it just in your local environment?

EDIT: I just saw your update. I’ll post an update to that shortly.

EDIT 2:

I’m not sure how SERVER variables are set when running a shell command, but in your console.php config file, you could force the correct host info by adding the following:




    'components'=>array(

        ...

        'request'=>array(

            'hostInfo'=>'http://domain.com',

        ),

    ),



The getBaseUrl() method should work correctly then.

It works, thank you B)