AbhimanuSharma
AbhimanuSharma

Reputation: 453

Simple home page in Codeigniter

First thing to learn about codeigniter should be how to create a simple view which is the appearance of your web application?. I had tried so many tutorials on Internet for making a MVC and always succeeded but when i try to make my own home page of site my myself i always failed.

The only thing that showed up is:

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

I just want a simple thing. When anyone open www.mywebsite.com my home page must be open.

Is this necessary to make a model if there is no database work in needed?

Now i tell you what i did myself to make my home page.
1. First of all i made a file 'index.php' in view folder (Simple HTML file).
2. I added a file 'index_controller.php' in controller folder. (see code below)

class Index_controller extends CI_Controller{
public function __construct()
{
    parent::__construct();
}

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

What more should i do to make my code working?

Upvotes: 1

Views: 762

Answers (1)

AdrienXL
AdrienXL

Reputation: 3008

Is this necessary to make a model if there is no database work in needed?

  • Nope.

You probably are missing one thing, the default controller. If you try now,

http://www.mywebsite.com/index.php/index_controller

it'll work right ?

But

http://www.mywebsite.com

won't because you have to tell codeigniter that it must load by default Index_controller.

You can define that in application/config/routes.php :

$route['default_controller'] = 'Index_controller';

Upvotes: 2

Related Questions