CodeIgniter has to be my favorite framework for PHP. The way it keeps out of your way while working to an MVC standard is something deserving of the highest praise.
For reasons passing understanding though the programmers of this excellent system have desided not to provide pretty URL’s out of the box. Getting infomation on this is a little tricky so here is my take on the situation.
Simply dump the following into a file called ‘.htaccess’ (Note the starting Dot) in the root path (thats the one at the very start of your path tree that should contain the ‘system’ folder).
1 2 3 4 5 6 | RewriteEngine on RewriteCond %{REQUEST_FILENAME} -f RewriteRule ^(.*)$ - [L] RewriteCond $1 !^(index\.php|images|robots\.txt) RewriteRule ^(.*)$ /index.php/$1 [L] |
As with most mod_rewrite hacks you will need that enabled on an apache server. Its very rare to find a hosting company that doesn’t use this setup so you should be fine.
You will also need to change the following variable to a blank value in the system/application/config/config.php file:
1 | $config['index_page'] = ''; |
And you’re done. From now on your Urls are addressed in the form: http://SITE/CONTROLLER/METHOD/VALUE1/VALUE2 (e.g. http://mysite.com/users/edit/123123)