3

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.

Bushra Shahid
  • 781
  • 7
  • 20
  • have you enabled mod rewrite module. you have remove index.php in config.php file – Sundar Mar 23 '15 at 08:05
  • yes . i have already mention this in my question and i have already removed index.php form config file. – Bushra Shahid Mar 23 '15 at 08:06
  • http://stackoverflow.com/questions/19183311/codeigniter-removing-index-php-from-url duplicate – Sundar Mar 23 '15 at 08:07
  • 1
    i did every thing which are suggested in above Ref . but still facing same problem. – Bushra Shahid Mar 23 '15 at 08:13
  • Sometimes, and that is depending on server (GoDaddy for example), you need to append question mark after `index.php`. I.e. `RewriteRule ^(.*)$ /index.php?/$1 [L]`. Also google for *far in space codeigniter htaccess* and try to use code provided. – Tpojka Mar 23 '15 at 08:41
  • i checked every thing and could not find where i m making mistake. :( – Bushra Shahid Mar 23 '15 at 11:18

3 Answers3

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

Joe
  • 4,618
  • 3
  • 28
  • 35
1

This should help you,

RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^(.*)$ index.php/$1 [L,QSA]
Niranjan N Raju
  • 12,047
  • 4
  • 22
  • 41
0

check this code of htaccess file.

DirectoryIndex index.php    
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|public|images|css|js|robots\.txt)    
RewriteRule ^(.*)$ index.php?/$1 [L]

you can find your answer refference here

My .htaccess file is not working

moreover can you share your base url with us? as this error may be due to wrong baseurl set.

Community
  • 1
  • 1
Imran Qamer
  • 2,253
  • 3
  • 29
  • 52