phphtmlurlurl-routingpublic-html

How to structure public_html folder


My project is currently accessible like that:

website.com/development/views/index.php

My question is should I use URL rewriting to hide /development and /views and put index.php in the main /public_html folder or get rid of the /development folder? The issue with that is there are a bunch files from my hosting provider in public_html, so I wouldn't want to mix it with my application.


Solution

  • Whilst it is a matter of preference, the standard practice in most php applications, I have seen is to have the index.php file in the root folder.

    Instead of this

    website.com/development/views/index.php
    

    Most developers would expect something like this

    website.com/development/index.php
    

    Folder structure:

    development
            |
             ---views
             ---js
             --- css
             --- index.php 
    

    The index.php file should sit at the same level as your views folder.