Reputation: 449
I have 3 controllers are home, food, and drink. home controller I want to make the default controller. and I wrote in routes.php file like this:
$ route ['default_controller'] = "home";
$ route ['404_override '] ='';
then i made the code in each controller as below:
controller home.php
class Home extends CI_Controller{
public function __construct() {
parent::__construct();
}
public function index(){
}
public function info(){
}
}
controller food.php
class Food extends CI_Controller{
public function __construct() {
parent::__construct();
}
public function index(){
}
public function foodMenu(){
}
public function foodJenis(){
}
}
controller drink.php
class Drink extends CI_Controller{
public function __construct() {
parent::__construct();
}
public function index(){
}
public function drinkMenu(){
}
public function drinkJenis(){
}
}
I want to make this url like www.mydomain.com/home, www.mydomain.com/food, www.mydomain.com/food/foodmenu, www.mydomain.com/food/foodjenis, www.mydomain.com/drink, www.mydomain.com/drink/drinkmenu, www.mydomain.com/drink/drinkjenis.
but when I was on the url www.mydomain.com/food/foodmenu and I headed to www.mydomain.com/food/foodjenis, but the url that appears is www.mydomain.com/food/food/foodjenis. "food" controller name in the url it into two. how to handle it. please help me. thank you :(
Upvotes: 0
Views: 238
Reputation: 832
did you set base url in config file in CI ?If yes. try with relative paths. like food/foodjenis
<a href="<? php echo base_url('food/foodjenis') ?>"></a>
Upvotes: 0
Reputation: 63
How do u make your links?
I think there is problem u try to make relative linking and html is looking at food as a folder so when u make link as
<a href="food/foodjenis"></a>
it will make link as u wrote www.mydomain.com/food/food/foodjenis
But if u use CI url
<a href="<? php echo site_url('food/foodjenis') ?>"></a>
It shall work like u intended.
Upvotes: 1
Reputation: 3586
One way to solve is through the use of base
tag.
Somewhere in the document head (before including any css or js) put
<base href='http://mysite.com'>
After that you can freely use relative links in your CI applications.
Upvotes: 1