Posted inCodeigniter

Codeigniter – How to get current url in controller or view ?

Today, We want to share with you get current url in codeigniter.In this post we will show you codeigniter gets currents site url, hear for get currents controller name we will give you demo and example for implement.In this post, we will learn about PHP – How To Get Currents Url Using CodeIgniters Controller’s URL From A View with an example.

Codeigniter get current url On View Controller Model Example

Using Helper function

Make Sure the Url Helper is loaded before calling the function –


load “url” helper before use current_url()


$currentURL = current_url();

How to get currents url with its get request?

Load the URL helper To get currents url

echo $this->input->get('my_id');


// Load the URL helper To get currents url

$currentURL = current_url(); //http://myhost/main

$params   = $_SERVER['QUERY_STRING']; //my_id=1,3

$fullURL = $currentURL . '?' . $params; 

echo $fullURL;   //http://myhost/main?my_id=1,3

For currents url

echo base_url(uri_string());

I hope you get an idea about CodeIgniter -> Get currents URL relative to base url.
I would like to have feedback on my blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

I am Jaydeep Gondaliya , a software engineer, the founder and the person running Pakainfo. I'm a full-stack developer, entrepreneur and owner of I live in India and I love to write tutorials and tips that can help to other artisan, a Passionate Blogger, who love to share the informative content on PHP, JavaScript, jQuery, Laravel, CodeIgniter, VueJS, AngularJS and Bootstrap from the early stage.

Leave a Reply

Your email address will not be published. Required fields are marked *

We accept paid guest Posting on our Site : Guest Post Chat with Us On Skype