I use codeigniter. I want to get the current location of the page without some segments.
Example:
my current location: "localhost/ci/site/home/all/1"
I want to get this: "localhost/ci/site/home/all"
I already tried: current_url() but it gives me:
"localhost/ci/site/home/all/1"
Sorry for my terrible english :(
echo base_url().$this->uri->segment(1).$this->uri->segment(2);
1 segment for controller, 2 for method. base_url returns your site base url. Don't forget include URI helper.
Try this :
$query = $_SERVER['QUERY_STRING'] ? '?'.$_SERVER['QUERY_STRING'] : '';
echo $this->config->site_url().$this->uri->uri_string(). $query;