Rabiul Islam Sohag
Rabiul Islam Sohag

Reputation: 21

how can i link a new page in codeigniter

this is my link

 href="<?php echo base_url();?>views/contact"

controller code here

 class S extends CI_Controller {

public function index()
{
    $this->load->view('header');
    $this->load->view('banner');
    $this->load->view('content');
    $this->load->view('footer');
}

public function contact()
{
    $this->load->view('contact');
}

}

my output :

404 Page Not Found The page you requested was not found.

plese help me....

Upvotes: 2

Views: 4751

Answers (3)

Alaa M. Tekleh
Alaa M. Tekleh

Reputation: 7906

to make custom route for a page you can add the route of page and the controller action in config/route.php as follows

$route['contact'] = 's/contact';

then you can request the page from any place as the following by using site_url() method

<a href="site_url('contact')">Contact</a>

note you need to load url helper to use this method you can autoload it in config/autoload.php

I hope my answer would be useful

Upvotes: 0

Nicolas P.
Nicolas P.

Reputation: 84

Did you declare the route in the config/route.php file ? See this link to description

Upvotes: 1

JYoThI
JYoThI

Reputation: 12085

href should be controller name and function name not view folder name

try this

href="<?php echo base_url();?>s/contact"

Upvotes: 1

Related Questions