Codeigniter

Starting Out – Part 2

OK.. So I got some real basic “proof of concept” stuff working in Codeignitor. A really basic CRUD application, and have an idea on organizing code into folders to follow the website menu structures.

Next on the list is eliminating the “index.php” from the website URL. Seems simple enough according to the documentation. But…

First, in the config file (application/config/config.php) you need to change the index_page reference to this:
$config[‘index_page’] = “”;

Second, you need to add an .htaccess file to the “root” directory of your website – where the Codeignitor index.php file is.

Third – you may need to change the “uri_protocol” value in the config to “REQUEST_URI”

The htaccess file tripped me up. The example they give in the Codeignitor documentation is followed by a warning :
These specific rules might not work for all server configurations.

And, of course, they did not. So, a crash course about htaccess files and now it works. What I wound up using looks like the following:

RewriteEngine on
RewriteBase /
RewriteCond $1 !^(index.php|resources|robots.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]

But, I may need to tweek that later on.

Leave a Reply

Your email address will not be published. Required fields are marked *