azad chouhan azad chouhan - 6 months ago 14
PHP Question

How to remove the index.php from url in codeigniter project

I am creating a website in Codeigniter. This is very common issue I know and there are lots of solutions on Stack Overflow. I try almost all but nothing is helpful for me.

I just want to remove index.php from my url. Anybody please tell me how can I do it?

I have removed index.php from the config file's

$config['index_page']
section

I also checked
$config['uri_protocol'] = 'AUTO';
mode try both mode auto and
REQUEST_URI
.

My .httaccess file structure right now is this:

<IfModule authz_core_module>
Require all denied
</IfModule>
<IfModule !authz_core_module>
Deny from all
</IfModule>

<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>


Can anybody please tell me how to do it?

Answer

=>Change in config file :

$config['base_url'] = 'http://123456/proj/';
$config['index_page'] = '';

=>change in .htaccess file:

RewriteEngine on

RewriteCond $1 !^(index\.php|(.*)\.swf|forums|images|css|downloads|jquery|js|robots\.txt|favicon\.ico)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ ./index.php?$1 [L,QSA]
Comments