JSOPanel Get started
Help Center › Website Owners › Serving a site from a public subfolder (Laravel and similar)

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

  1. Click Domains & SSL in the sidebar and click Manage next to the domain.
  2. Click the Web server tab.
  3. Find Folder to serve from.
  4. Type the folder's name, for Laravel this is public.
  5. 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.

Tip: leave this field empty for an ordinary site, where every file is meant to be part of the public site. Only set it for an application that's specifically built to keep its own program files separate from what it serves, check that application's own documentation if you're not sure whether it needs this.

Changing it back

Clear the field and click Apply again to go back to serving the whole site, the usual setup for most applications.