In this tutorial, we will see how to create a codeigniter application folder outside root level on server. Good thing with CI is that it is highly configurable and the application can be set up above the root level even on a shared hosting account e.g. Godaddy. All security experts advise to have the code hosted outside the root of your hosting to avoid your code being exposed to hackers in case of any security vulnerabilities or issues with your hosting server.
Ok, lets get started
- First download the Codeigniter version you want to use from website : http://www.codeigniter.com/download
- Let us assume that you want to serve your application from the folder root (e.g. \citest\root) which means your index.php file will be inside /root folder.
- Now create another folder outside root folder. For this example , we have created a folder named aboveroot inside the same folder as root.
- Below is how it will look inside citest folder where our root and aboveroot folders are located:
- Now from the downloaded CI application copy the ‘application‘ and ‘system‘ folders inside the aboveroot directory. Below is how it should look:
- Now copy the index.php file in the root folder (and user_guide if you want the user guide available). Below is how it should look (files other than index.php are optional)
- Now the last and most important step. Open the index.php file and locate $system_path and $application_folder. Change them as below:
If you are using a different folder or path,make sure the correct relative location for ‘application’ and ‘system’ folder is updated in the index.php file.
That’s all, browse the root folder now and you should be able to see your website.
Below are some of the questions answered by this post