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

  • Home
  • SEARCH
  • 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

Could someone help me translate the following pseudo-code into code understood by Helicon Tech's
I am getting the following error and could use some help resolving it. Anyone
While reading a post on StackOverflow (http://stackoverflow.com/questions/1502081/im-trying-to-optimize-this-c-code-using-4-way-loop-unrolling), which is now marked as closed, I
Please help! I couldn't figure it out how to map the following situation: I
I hope someone could help me on this. I want to add a month
Is there something available that could help me convert a XSD into SQL relational
I'm kinda stuck with this one so I hoped someone could help me. I
OK, if anyone could help me with this I'd be much appreciative. If you
I recently ran into a problem that I thought boost::lambda or boost::phoenix could help
Could you help me fix the menu on this this page ? The menu

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.