Search code examples
php.htaccessweb-applicationsdirectory-structure

Directory Structure: Separating the application from uploaded files


I have a general question to do with application directory structure. I have my application and all the files required on a git repo that is regularly updated (PHP files, CSS, JS etc). And I have an uploads folder where users' uploaded avatars and files get stored.

Is it convention to separate these two parts of the app for example?:

public_html
    /app
    /uploads

or should the directory structure look more like this?:

public_html
    /index.php
    /css
    /js
    /uploads

When I merge changes from github I don't want any of my users' files to be affected.

  1. So should the app be physically separated from the uploads or should I just include /uploads to .gitignore?
  2. What if any .htaccess rewrites are required?

Solution

  • I think both structures are fine -- it's up to you. As long as the uploads are in a seperate folder, you can exclude that from versioning and you should be fine. Your .htaccess can be in the versioning system as well.