Here’s a quick tip to make cleaner looking URLs in CodeIgniter PHP framework. By default, if you have an application, the path of the application usually ends after index.php. Using Apache RewriteEngine, you can make cleaner looking URLs. You can have something similar to mysite.com/cigniter/MyApplication instead of mysite.com/cigniter/index.php/MyApplication
- Create a file named “.htaccess” inside your root CodeIgniter directory. It should look like the following:RewriteEngine on
RewriteCond $1 !^(index\.php|images|css|robots\.txt)
RewriteRule ^(.*)$ /[CODE IGNITER BASE]/index.php/$1 [L]where [CODE IGNITER BASE] is the directory of your Code Igniter install. For instance, if you named your base install folder “cigniter”, the Rewrite Rule would look like:RewriteRule ^(.*)$ /cigniter/index.php/$1 [L] - If you get an error, make sure your Apache install allows for RewriteEngine in that particular folder. This is usually located in /etc/apache2/sites-enabled/YOURSITE The folder needs to have permissions of:AllowOverride AuthConfig
Options +FollowSymlinksSee: http://www.whoopis.com/howtos/apache-rewrite.html - More info on CodeIgniter framework:
http://codeigniter.com/