Codeigniter posted double link in address bar when clicking href

help me with this code.

 <a href="<?php echo site_url('calculator/');?>"><< Kembali menghitung</a>

when i click the link it posted double like : http://localhost/belajarci/index.php/calculator/localhost/belajarci/index.php/calculator

ive tried to remove the href values but the page not refered to the home, its only change another value in my code.

Upvotes: 3

Views: 821

Answers (2)

Jinandra Gupta
Jinandra Gupta

Reputation: 545

It's right it's redirecting on double url becasue of you need to include $this->load->helper('url') in your file / controller constructor or use url helper in autoload.php

Also do two things in your configuration:

  1. Check the .htaccess file in project becasue may be you have set there any url redirect.
  2. Check in config file for base url what you have set there.

Upvotes: 1

devpro
devpro

Reputation: 16117

You are getting this URL:

http://localhost/belajarci/index.php/calculator/localhost/belajarci/index.php/calculator

Because you need to include $this->load->helper('url') in your file / controller constructor or use url helper in autoload.php

After loading url helper your URL will work as you need.

You can also follow the CI User Manual: https://codeigniter.com/userguide3/helpers/url_helper.html

Upvotes: 1

Related Questions