How to Get the Current URL in CodeIgniter

Using Helper function

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

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

load “url” helper before use current_url()

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


$currentURL = current_url();
print_r($currentURL);

How to get currents url with its get request?

Load the URL helper To get currents url

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

//or

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


#codeigniter #url 

How to Get the Current URL in CodeIgniter
1.00 GEEK