If you are like Silicon Dales, a few years back, you would have used CodeIgniter (CI) probably quite a lot 5-6 years ago, but perhaps not so much “these days” on projects.
We have a number of clients with legacy CI sites, and sometimes, we need to move them around and configure them.
For this reason, sometimes its necessary to find things like where config.php, database.php files live, and keep a snippet or two around for future reference, because we don’t deal with CI so much these days!
On a recent transfer, as often, the outgoing host had hidden .htaccess files, and we wanted to make sure that the new site had working pretty permalinks, which use mod_rewrite. You may find yourself in a similar situation, so below is a default, simple, CI .htacces file which can help you to make your permalinks mod_rewrite successfully!
.htacces for mod_rewrite using CI
See the code to add in to your .htaccess file in the Gist below.
Where to add this
This .htaccess file should be added to the root of your CodeIgniter domain – so if your site lives in a /htdocs/ folder, place it directly into that directory.
This is the standard .htaccess for CI
Please note, I did not invent this. Its the standard .htaccess for CodeIgnitor which was originally submitted by Elliot Haughin. Props to Elliot. All I did was dig it out and post it here for easy future reference.
Not working? Leave a comment
Leave a comment below if this helped you and make us feel a little bit better about our day!
Working to access a view I created called ‘about_page.php’ by simply typing in localhost/ci/about but currently I can only access it by using localhost/ci/index.php/about. I’ve searched for an answer to this issue, but haven’t been able to search one. Could anyone help for this?
Sounds like a .htaccess issue, based on the need for index.php in the url. Check your rewrite rules are setup right, and also if your hosting supports this.