Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CodeIgniter removing index.php from url

I know this question has been asked a number of times. However, I still wasn't able to get rid of index.php url. It is preventing me to access my controller directly.

I am current using CodeIgniter 2.2.2.
And the following is my .htaccess file:

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

application/config:

//  Find the below code

$config['uri_protocol'] = "AUTO"

//  Replace it as

$config['uri_protocol'] = "REQUEST_URI" 

Any Idea? Thanks in advance for your time.

like image 871
CS Learning 101 Avatar asked Aug 11 '26 00:08

CS Learning 101


1 Answers

Use below code in your .htacess

   DirectoryIndex index.php
    RewriteEngine on
    RewriteCond $1 !^(index\.php|images|css|js|robots\.txt|favicon\.ico)
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ ./index.php/$1 [L,QSA]
like image 162
Techie Avatar answered Aug 13 '26 12:08

Techie



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!