first we adding (.htaccess)(it is only extention file) file extention in our project directory
it is my project file directory location
http://localhost/demoproject
demoproject is my project name
copy below code and create (.htaccess) file and paste it under (.htaccess) file
these file create under project directory
Options +MultiViews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
# Disable Directory Browsing
Options All -Indexes
one more (.htaccess) file create into view folder
copy below code and paste it under newly created (.htaccess) file
<IfModule authz_core_module>
Require all denied
</IfModule>
<IfModule !authz_core_module>
Deny from all
</IfModule>
normally code controller file
DemoController.php
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class DemoController extends CI_Controller
{
public function index()
{
$data['demo'] = 'hello world';
$this->load->view('DemoView', $data);
}
}
enter code here
normally code our view file
DemoView.php
<!DOCTYPE html>
<html>
<head>
<title>demo</title>
</head>
<body>
<h1>
<!-- $demo is the $data of object that defind our DemoController. -->
<?php echo $demo ?>
</h1>
</body>
</html>
run localhost and only type localhost/project_name/controller_name
here we use demoproject as project name and DemoController as controller name
http://localhost/demoproject/DemoController
if your code not execute then please comment