0

I understand that it is a good idea to keep some files outside public_html for security reasons. What about js files? Should I keep all my js files (such as angularjs') in public_html or outside?

If I keep them outside public_html, it is going to be difficult to execute them on the browser, isn't? How can I execute them then if they are stored outside public_html directory?

It must be the same for CSS files too, right?

oasis
  • 197
  • 2
  • 13

2 Answers2

2

Well, since the JavaScript files, including your use of Angular, is required to be executed in the client's browser, they must be available somewhere below the public_html directory. The same goes for any html and CSS file your site is using.

An example of files you don't want to be public available could be a file based database such as SQLite.

Elisabeth
  • 71
  • 1
  • 2
  • 7
  • I understand that now thanks. but how come Zend stores html files (as phtml) outside public? they are store in `module/YourModuleName/view/.../`, such as `module/YourModuleName/view/.../index.phtml`? – oasis Apr 03 '15 at 13:57
  • 1
    If you are serving up a html file to be viewed, ie. index.html, it has to be publicly available. However if a php file is requested (as in the case with Zend), it can just read the non publicly available .phtml files and render them through itself. – cwurtz Apr 03 '15 at 14:03
  • Yep, that would make sense. Thanks for elaborating on that CJ Wurtz. – Elisabeth Apr 03 '15 at 14:05
1

Everywhere I have worked, the CSS and JS files are stored inside public_html so that they can be referenced/loaded by the "public".

rfornal
  • 5,072
  • 5
  • 30
  • 42