Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Base URL in Kohana 3

Tags:

php

kohana-3

How do I get the base URL in Kohana 3?

Is there a solution in raw PHP?

like image 652
ed. Avatar asked Nov 29 '22 06:11

ed.


2 Answers

In Kohana it's

echo url::base();

http://docs.kohanaphp.com/helpers/url


In raw PHP

echo "http://".$_SERVER['HTTP_HOST']."/NameOfApp";
like image 199
Gerard Banasig Avatar answered Dec 12 '22 01:12

Gerard Banasig


For Kohana 3, it's URL::base().

From the doc:

// Absolute URL path with no host or protocol
echo URL::base();

// Absolute URL path with host, https protocol and index.php if set
echo URL::base('https', TRUE);

// Absolute URL path with host and protocol from $request
echo URL::base($request);

Ref.: http://kohanaframework.org/3.1/guide/api/URL

like image 30
gimpe Avatar answered Dec 12 '22 02:12

gimpe