Search code examples
phphtmlwebvs-web-site-project

Which is the standard way to organize files on a website?


I'm working on a project that includes both server and website design. Becouse my project includes php files that receive ajax requests, php files that contain classes and so more, I was wondering where do i'm supposed to store all this, becouse i know that ussually the html, js and css files go in folders like www/website/js, www/website/css, www/website/img, etc. But the files that the user is not supposed to know where they are, and is not supposed to have access to, where do I put them?


Solution

  • You put them outside of the directory that is accessed with a link to "http://wwwexample.org/" - the directory where your index.html or index.php file is located is this directory. Like "www/website" in your example. Any directory one step up (like "www") would be suitable, or any additional directory created there.

    www/
     |- website/
     |  |- index.html
     |  |- js/
     |     |- jquery.js
     |
     |- secure-data/
        |- passwords.php
    

    Note that you have to put some PHP script into that website directory to allow users to access them, but you usually only put a short code into them to allow to load more code from outside of this directory. There is one big difference when accessing PHP files: One way is via the web server, the other one is via the file system - and the way via web server is more limited, i.e. you cannot go ANYWHERE, you have to stay in the area below that directory the web server is presenting to the world.