Serving a site from a public subfolder (Laravel and similar)
Keep your application's framework and .env file off the web by serving only its public folder, the way Laravel is built.
Some applications, Laravel being the best-known example, are deliberately built with their framework code, configuration, and .env file sitting above the folder meant to be reachable over the web, and only expose a public folder inside as the actual document root. If a site like this is served from the whole account folder instead, everything above public, including secrets in .env, becomes reachable to anyone who requests it directly.
If you installed it through Web Applications
Installing Laravel through the one-click installer already sets this up correctly for you, nothing further to do. This article is for when you've deployed it another way, uploaded the files yourself, or connected it through Git Deployment.
Setting it yourself
- Click Domains & SSL in the sidebar and click Manage next to the domain.
- Click the Web server tab.
- Find Folder to serve from.
- Type the folder's name, for Laravel this is
public. - Click Apply.
Everything above that folder stays on disk, used by the application as normal, but is no longer reachable over the web at all. The page shows what's currently being served right next to the field, so you can confirm it took effect.
Changing it back
Clear the field and click Apply again to go back to serving the whole site, the usual setup for most applications.