Codeigniter index.php page Codeigniter index.php page codeigniter codeigniter

Codeigniter index.php page


You can't delete index.php file from root directory, instead of that you can remove index.php from the url.

You have to define default controller first, then do follow steps

Have the.htaccess file in the application root directory, along with the index.php file. (Check if the htaccess extension is correct , Bz htaccess.txt did not work for me.)

And Add the following rules to .htaccess file,

RewriteEngine OnRewriteCond %{REQUEST_FILENAME} !-fRewriteCond %{REQUEST_FILENAME} !-dRewriteRule ^(.*)$ index.php/$1 [L]  

Then find the following line in your application/config/config.php file

$config['index_page'] = 'index.php';

Set the variable empty as below.

$config['index_page'] = '';

That's it, it worked for me.

If it doesn't work further try to replace following variable with these parameters ('AUTO', 'PATH_INFO', 'QUERY_STRING', 'REQUEST_URI', and 'ORIG_PATH_INFO') one by one

$config['uri_protocol'] = 'AUTO';


$config['index_page'] = '';

will do the trick

from now if you access your site like:

http://mypage.com

the default controller would be called

you can change it in routes.php file in your application/config folder

like:

$route['default_controller'] = "views/index";

Btw. your views.php controller in (application/controllers) should look like somehting like that:

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');class Views extends CI_Controller {    public function index()    {        $data = "Text from controller's index method";        $this->load->view('myview', $data);    }}

And your myview.php in (application/views):

<?php echo $data; ?>