0

I just installed the php framework CodeIgniter 3 and it seems that JS,CSS and images should be placed OUTSIDE Application folder. If not, link to those files inside views does not run.

For many reasons I would like to have these kind of files inside application/views folder. I think that I should correctly set .htaccess file, but I would also like to "lower my defenses less possible", so give only strict necessary privileges.

How to do it? Thank you.

5
  • Don't do it. It's a bad idea.
    – ceejayoz
    Jan 14, 2015 at 21:59
  • Ok, could be a bad idea from your point of view, but sometimes there are needs that are not ideal, but necessary for many reasons. I only would like to know how to set up my system in a specific case like this. Jan 15, 2015 at 7:52
  • There shouldn't ever be a need to do this. Images, JavaScript, and CSS files are not views and should not be in the views folder for that reason. Your application folder shouldn't ever be accessible by the web server for critical security reasons.
    – ceejayoz
    Jan 15, 2015 at 13:45
  • Let's consider to download and integrate a complex 3rd party plugin which include .php, .js, .css files. Generally all files are inside a folder with the plugin name. With standard CodeIgniter folder tree, I need to split each file in different folders instead of mantain all grouped, right? .php (=views) files in application/view, .css in assets/css, .js in assets/js. Am I correct? It seems very uncomfortable Jan 15, 2015 at 13:54
  • You'd likely want to turn it into a package for something like getsparks.org. You can also use stuff like Grunt/Gulp to handle moving assets into the right locations on deploy.
    – ceejayoz
    Jan 15, 2015 at 14:13

1 Answer 1

0

Do like this:

RewriteEngine on
RewriteCond $1 !^(index\.php|uploads|assets|js|images|css|robots\.txt)
RewriteRule ^(.*)$ /your_ci_folder/index.php/$1 [L]
2
  • Thanks, can you explain me what does it mean? I would like to better understand in order to lower defenses as low as possible. thanks Jan 15, 2015 at 15:43
  • Sorry i didnt mention the .htaccess, load your assets from .htaccess file and the above should be in your .htaccess file. Jan 15, 2015 at 16:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.