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]
2
  • 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 Commented Jun 13, 2012 at 14:19
  • Gotcha!! Possible duplicate: stackoverflow.com/questions/5155333/… Somebody close this question cause I dont have enough rep to do so.. Commented Jun 13, 2012 at 14:24

3 Answers 3

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]
Sign up to request clarification or add additional context in comments.

Comments

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]

1 Comment

Yup I had this. Didn't post this to keep the question short. If the above problem is solved, this would work too
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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.