I have create a controller in codeigniter. The problem is that when I hit the controller name and function name in url then Its give me error that 404 not found. I am new to codeigniter and I did not understand where I am going wrong
Here is my controller
JavaScript
x
<?php
if(!defined('BASEPATH')) exit('No direct script access allowed');
class Home extends CI_Controller{
function __construct(){
parent::__construct();
}
function you(){
$this->load->view('home_view');
}
}
?>
and my view is like this
JavaScript
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>My First CodeIgniter Practice</title>
</head>
<body>
<h1> HELLO CI Buddy!</h1>
</body>
</html>
I am creating my first project on codeigniter and I stuck in this problem.I already try most of the solution from the stackoverflow and after that I asking this question. So Its my request not to add this question to duplicate. I want solution for my problem. any help is appreciable
Thanks
Advertisement
Answer
Your issue may be due to any of the following reason
- First letter of your controller file name should be in capital letter ie Home.php .
- Please check your home page file name
- Use the URL localhost/w3crud/index.php/home/you if the issue is in your url then edit your .htaccess file