Removing index.php in Codeigniter HMVC

1.3k Views Asked by At

I am tried to remove index.php in Codeigniter HMVC. But I Could not complete with the following code.

 <IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>

I placed .htaccess file in root directory and removed index.php from config file. Still I'm facing the same problem.

4

There are 4 best solutions below

0
disha On

in your config.php file put

$config['index_page'] = "";
$config['uri_protocol'] = "REQUEST_URI";

Then in .htaccess file put

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
</IfModule>

Now, check your url removing index.php. It will work.

0
Vijay Sharma On

Please follow some step:

  1. goto application/config/config.php : replace $config['index_page'] = 'index.php'; to $config['index_page'] = ''; and $config['uri_protocol'] = 'REQUEST_URI'; to $config['uri_protocol'] = 'AUTO';

  2. enable rewrite mode by
    sudo a2enmod rewrite then service apache2 restart

  3. if you'd like, you can use the following .htaccess file.

<IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule>

0
shashank panchal On

Simply create one new file .htaccess.

And past it the below code into the .htaccess file.

Then go into the project folder follow the path application->config->config.php

into the config.php file

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


RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^(.*)$ /example/index.php/$1 [L]

// into the above line example is the project name, you have to replace the example to your project name

1
labkoding On
RewriteBase /g-pos  /// Your htdocs
RewriteEngine On
Options -Indexes
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]