In this post I’ll show how to set up CodeIgniter in a way that your code and configuration (passwords!) are safe. It will involve moving the “system” and “application” outside the (public) document root.
Seperating both <em>system</em>' and application’ has obvious advantages for maintainance and for reusibility. Using a seperate `www’ directory enables you to publish all your application specific JS/CSS and other public files.
The first thing we need to do is to create an checkout of the latest CodeIgniter release (currently 1.7.1)
<div class=’bogus-wrapper’>$ svn checkout http://dev.ellislab.com/svn/CodeIgniter/tags/v1.7.1/ somepathoutsidedocumentroot
</pre></td></tr></table></div>
now move the application folder outside the system folder:
1 2 | |
Now move the system and application folder to some folder outside of your public
document root. Let’s call this directory <em>non-www</em>'. The documentroot
directory will be called www’.
In the root of your checkout you will find an index.php. Copy/move this file to www. Open it and look for the following lines:
1 2 | |
Change them to the following:
<div class=’bogus-wrapper’>$system_folder = "../non-www/system";
$application = "../non-www/application";
</pre></td></tr></table></div>
Now you are up and running. Probably you want something like nice url’s. For this you can use the following .htaccess
1 2 | |
1 2 | |
Now, go and create some new shiny sites.