1

I am having problems removing index.php from codeigniter-2. I remember using the same code before too & it worked perfectly fine, but it is not working on codeigniter-2.

I have checked the documentation & this question too, still of no help.

My .htaccess code is as follows:

RewriteEngine On
RewriteBase /

RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/$1 [L]

RewriteCond %{REQUEST_URI} ^application.*
RewriteRule ^(.*)$ /index.php?/$1 [L]

RewriteCond $1 !^(index\.php|images|robots\.txt|css)
RewriteRule ^(.*)$ ./index.php/$1 [L]
Community
  • 1
  • 1
  • I remember seeing this kind of question before on SO. Just wait till I find it! Till then check my answer below. It would work – gopi1410 Jun 13 '12 at 14:19
  • Gotcha!! Possible duplicate: http://stackoverflow.com/questions/5155333/remove-index-php-from-url-codeigniter-2 Somebody close this question cause I dont have enough rep to do so.. – gopi1410 Jun 13 '12 at 14:24

3 Answers3

1

replace /index.php with /site_folder_name/index.php everywhere & be sure that your server supports mod_rewrite

Your new code should look like:

RewriteEngine On
RewriteBase /

RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /site_folder_name/index.php?/$1 [L]

RewriteCond %{REQUEST_URI} ^application.*
RewriteRule ^(.*)$ /site_folder_name/index.php?/$1 [L]

RewriteCond $1 !^(index\.php|images|robots\.txt|css)
RewriteRule ^(.*)$ /site_folder_name/index.php/$1 [L]
gopi1410
  • 6,567
  • 9
  • 41
  • 75
0

try this:

RewriteEngine On
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
csotelo
  • 1,453
  • 2
  • 28
  • 43
  • Yup I had this. Didn't post this to keep the question short. If the above problem is solved, this would work too –  Jun 13 '12 at 14:21
0

you have to re-write the .htaccess file for this.

maximum server work with this

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

in godaddy server i have to write this. sometimes it works with above code in godaddy server.

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*) index.php?/$1
Ivan
  • 81
  • 1
  • 3