Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get full site home URL in Kohana 3

I installed Kohana (in a "kohana" directory in my xampp public folder) and I'm trying to get the full base URL with the domain and protocol.

When I try:

url::base();

I only get /kohana/ back as a result, but want http://localhost/kohana/ instead.

Is it possible to do this in Kohana, or must I use standard PHP?

like image 667
Marek Avatar asked May 26 '10 23:05

Marek


1 Answers

You don't have to extend anything, just use URL::site with the protocol parameter:

$base_url = URL::site(NULL, TRUE);

This will generate a base URL with the current protocol. If you want to use a specific protocol:

$base_url = URL::site(NULL, 'http');

No need to reinvent the wheel here!

like image 84
shadowhand Avatar answered Nov 04 '22 08:11

shadowhand