Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 781071
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T20:10:32+00:00 2026-05-14T20:10:32+00:00

could you help me with following questions. How do i get the: absolute/relative current

  • 0

could you help me with following questions.
How do i get the:

absolute/relative current url

  • http://www.example.com/subdir/controller/action
  • /subdir/controller/action

absolute/relative application url

  • http://www.example.com/subdir/
  • /subdir/

I could of course use native php to get it but i think i should rather use ko3 functions.

Any idea how that works?

Thanks in advance!

  • 1 1 Answer
  • 3 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T20:10:32+00:00Added an answer on May 14, 2026 at 8:10 pm

    Tried to make a controller that outputted them all correctly. Let me know if any of them are off.

    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 this:

    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/
            )
    )
    

    Technically speaking, it’s actually only the first page url that is a real relative url, since all the others either start with / or http://.


    Needed to get the url for the current page myself, so decided to extend the url class. Thought I could share it here. Let me know what you think 🙂

    /**
     * Extension of the Kohana URL helper class.
     */
    class URL extends Kohana_URL 
    {
        /**
         * Fetches the URL to the current request uri.
         *
         * @param   bool  make absolute url
         * @param   bool  add protocol and domain (ignored if relative url)
         * @return  string
         */
        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();            //  controller/action
    echo URL::current(TRUE);        //  /base_url/controller/action
    echo URL::current(TRUE, TRUE);  //  http://domain/base_url/controller/action
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Do you think jquery could help me get the following script work faster? Thanks!
Could someone help me with the following two questions? How can I filter on
Could one help translating following sed command so it does the same on aix
I was hoping someone could help me with the following script: jQuery(document).ready(function($) { $(.infoBoxBtn
Could anyone help me to understand following line of code: sol< ?=f((1<< n)-1,i,0)+abs(P[i])*price; I
Could someone help me clarify the following conecpts, and the relationship among them ?
could soemone help me with the following condition, please? I'm trying to compare $price
I'm using Firebird 2.1. I could use some help creating the following query or
Iam getting the following error , could some one help me how to fix
Got 2 htaccess questions, hopefully you could help me out: 1) Why do these

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.