CodeIgniter URLs use Uniform Resource Identifiers (URI). In simple terms, CodeIgniter's URLs are simply segments. These segments are then split up and used to load a particular controller and method. Here is a typical CodeIgniter URL:
Everything after the index.php
segment is used by CodeIgniter to determine what to load. The first segment is the name of the Controller. The second segment is used to determine which function to load—if this is blank then the index function will be used.
The final segment will be used to pass any data to the function.
You can remove the index.php
part of the URL by adding a .htaccess
file to the root of your CodeIgniter install. Here is an example file:
RewriteEngine on RewriteCond $1 !^(index\.php|images|robots\.txt) RewriteRule ^(.*)$ /index.php/$1 [L]
This will redirect anything to the index.php
file except for index.php
, the images
folder, and robots.txt
. You can add any other items to the list as you so wish, such as a folder for .css
files or even JavaScript files.