I tried to make a controller that correctly displayed them. Let me know if any of them are disabled.
class Controller_Info extends Controller { public function action_index() { $uris = array ( 'page' => array ( 'a' => Request::instance()->uri(), 'b' => URL::base(TRUE, FALSE).Request::instance()->uri(), 'c' => URL::site(Request::instance()->uri()), 'd' => URL::site(Request::instance()->uri(), TRUE), ), 'application' => array ( 'a' => URL::base(), 'b' => URL::base(TRUE, TRUE), 'c' => URL::site(), 'd' => URL::site(NULL, TRUE), ), ); $this->request->headers['Content-Type'] = 'text/plain'; $this->request->response = print_r($uris, true); } public function action_version() { $this->request->response = 'Kohana version: '.Kohana::VERSION; } public function action_php() { phpinfo(); } }
Outputs the following:
Array ( [page] => Array ( [a] => info/index [b] => /kohana/info/index [c] => /kohana/info/index [d] => http://localhost/kohana/info/index ) [application] => Array ( [a] => /kohana/ [b] => http://localhost/kohana/ [c] => /kohana/ [d] => http://localhost/kohana/ ) )
From a technical point of view, this is actually only the first URL of the page, which is the real relative URL, since all the others either start with / or http:// .
I need to get the URL for the current page, so I decided to extend the URL class. Thought I could share it here. Let me know what you think :)
class URL extends Kohana_URL { public static function current($absolute = FALSE, $protocol = FALSE) { $url = Request::instance()->uri(); if($absolute === TRUE) $url = self::site($url, $protocol); return $url; } } echo URL::current();
Svish
source share