Search Keyword:

04Nov

How to remove index.php in CodeIgniter (URL rewriting)

Posted by admin as CodeIgniter, PHP

This .htaccess rule is to remove the index.php file in CodeIgniter URLS.There is an example on how to remove this on the CodeIgniter User Guide but unfortunately it somehow doesn’t work.Anyway, here’s how to do it:

Put this code on your .htaccess file,changing “directory_on_where_is_your_CI” in which your CodeIgniter application resides.
If your CI application is in the root, just remove “directory_on_where_is_your_CI/” .

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

Put the .htaccess file on the root if your CodeIgniter application,where the system/ folder resides.To test if it is working try removing the index.php file in the URL.

example.com/index.php/news/article/my_article

can be

example.com/news/article/my_article

but produces the same output.

  • Digg
  • del.icio.us
  • Tumblr
  • StumbleUpon
  • Technorati
  • Reddit
  • NewsVine
  • Slashdot
  • DZone
  • Facebook
  • Twitter

9 Responses to How to remove index.php in CodeIgniter (URL rewriting)

Suresh

November 27th, 2009 at 9:38 am

Thank you. working fine :)

admin

November 27th, 2009 at 9:43 am

no problem,mate ;)

adzcer

January 22nd, 2010 at 12:44 pm

Thanks kabayan!

admin

January 22nd, 2010 at 1:48 pm

No problem! ;)

Aminul kabir

November 22nd, 2010 at 10:21 am

Hi,

Great, very perfect, very nice, working perfectly. A++++++++++++++++++++++++++++

Thanks

marc

July 27th, 2011 at 10:52 pm

good job, thanks

websourceblog

October 11th, 2011 at 6:49 pm

Thanks I was searching for this…..

Josh

October 30th, 2011 at 2:03 am

Same here, been searching everywhere for this! Massive kudos…

acecoder

December 13th, 2011 at 11:16 am

thanks…it works

Comment Form

Sponsored Links



Recent Comments

  • anup: thanx it helped me alot…
  • admin: try to look at window.location function of Javascript and place it under the success function of the AJAX...
  • ana: it works for me, but after success, how can i forward the url to a certain page? thanks
  • admin: Hello Don, do these steps again and again until the PSP reboots. Restore your PSP’s Default settings in SYstem...
  • don sb: my psp was already hacked then i changed the screen cos it broke,so at one point the battery lost total...