Yii Framework Forum: BaseUrl - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

BaseUrl Rate Topic: -----

#1 User is offline   bogdanroxanutza 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 4
  • Joined: 07-February 10

Posted 07 February 2010 - 12:09 PM

Hello!

How i can set a base url?

Example:

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!
0

#2 User is offline   Onman 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 175
  • Joined: 26-December 09
  • Location:The Netherlands

Posted 07 February 2010 - 02:11 PM

Yii::app()->request->hostInfo will give you the part before the baseUrl, e.g.
if you're running the site example.com hostInfo will be 'http://example.com/' (or 'https://example.com/').
if you're running the site on your local machine hostInfo will be 'http://localhost/' (or 'https://localhost/').
0

#3 User is offline   bogdanroxanutza 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 4
  • Joined: 07-February 10

Posted 07 February 2010 - 07:23 PM

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?
0

#4 User is offline   capsuline 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 41
  • Joined: 18-June 09
  • Location:Netherland

Posted 14 June 2013 - 01:18 AM

View Postbogdanroxanutza, on 07 February 2010 - 07:23 PM, said:

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
Yii::app()->user->baseUrl

0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users