Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Not Able to remove "Index.php" from URL in codeigniter

I am new in codeigniter and i am trying to remove index.php from URL in Codeigniter but not able to do this. I wrote code in my .htaccess file-

RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]

My Apache mod_rewrite is enable.

But still got 404 error when i am trying to access any controller without using index.php.

Please help.

Thanks.

like image 371
Bushra Shahid Avatar asked Mar 27 '26 05:03

Bushra Shahid


1 Answers

<IfModule mod_rewrite.c>
    RewriteEngine on 
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)/index/?$ $1 [L,R=301]
</IfModule>

Is the code I'm using, it works on every hosting platform I've used it on.

like image 195
Joe Avatar answered Mar 28 '26 18:03

Joe



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!