ItSolutionStuff.com

How to Get Current URL in Codeigniter?

By Hardik Savani November 5, 2023
Codeigniter

Sometimes, we need to get current URL path in your controller file or view file. So, we can get simply using "url" helper. Codeigniter provide url helper library that way we can get existing page url or base url etc.

current_url() through we can get current url in your Codeigniter application. But, you should load "url" helper before use current_url(). you can load url helper as bellow:

$this->load->helper('url');

In bellow example, you can see code how can i get current url in your controller file. So, let's see.

$this->load->helper('url');


$currentURL = current_url();

print_r($currentURL);

I hope it can help you...

Hardik Savani

Hardik Savani

I'm a full-stack developer, entrepreneur, and founder of ItSolutionStuff.com. Passionate about PHP, Laravel, JavaScript, and helping developers grow.

📺 Subscribe on YouTube