How i can set a base url?


When i do <?php echo Yii::app()->request->baseUrl; ?> i need to have a http://localhost/ … or whatever i want.

NOTE: i want to have http://localhost/css… or http://localhost/js… and not /js…

Thank you!

Yii::app()->request->hostInfo will give you the part before the baseUrl, e.g.

if you’re running the site hostInfo will be ‘’ (or ‘’).

if you’re running the site on your local machine hostInfo will be ‘http://localhost/’ (or ‘https://localhost/’).

Thanks for the reply.

Any way to set a baseUrl in my main.php?

What i don’t understand is why when i do echo Yii::app()->baseUrl i get nothing?

Try this