I'm new to codeigniter and was wondering where the best place is to store js/ css/ images/ etc? Typically I'm used to:
/
--/application
--/system
--/public
----/css
----/js
----/images
But what would be the best way to use such a directory structure? All that I've found in my research is that commonly codeigniter projects have their assets sitting next to the application and system folders.
Well, isn't it dangerous to have the data on the root level of the directory structure? All that is protecting the key folders (e.g. system) from outsiders is a .htaccess
Assuming you're running Apache, .htaccess
with deny from all
should be fine.
If not, this is one reason why you usually see something like this at the beginning of each file:
defined('BASEPATH') or exit('No direct script access.');
This ensures the script can't be accessed directly.
You may also be able to keep your application and system files below the web root, something like this:
htdocs
application
system
public_html
index.php
public
css
js
img...
Just use a relative path in index.php to define your CI paths:
$system_path = '../system';
$application_folder = '../application';