codeigniter – pretty urls

1 Kudos

In order to enable pretty urls using codeigniter make sure that the server is running with rewrite enabled. Then create a file named .htaccess with the following

<IfModule mod_rewrite.c>
RewriteEngine On

# below change myproj1 to your project name else if the project is in the root folder use /
RewriteBase /myproj1/

#Removes access to the system folder by users.
#Additionally this will allow you to create a System.php controller,
#previously this would not have been possible.
#'system' can be replaced if you have renamed your system folder.
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/$1 [L]

#Checks to see if the user is attempting to access a valid file,
#such as an image or css document, if this isn't true it sends the
#request to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
#This last condition enables access to the images and css folders, and the robots.txt file
#Submitted by Michael Radlmaier (mradlmaier)
RewriteCond $1 !^(index.php|images|robots.txt|css)
RewriteRule ^(.*)$ index.php?/$1 [L]

and copy the .htaccess to the root folder of your project. This is the folder which contains index.php and the folder system

VN:F [1.9.22_1171]
Rating: 5.0/5 (1 vote cast)