How to Serve a Laravel Application from the Public Folder Using .htaccess

This guide explains how to configure your website so that your Laravel application loads directly from the /public directory when visitors access your domain, without showing /public in the URL.

By default, Laravel’s entry point is the public folder. If Laravel is installed inside your primary domain’s root directory (usually public_html), you can use .htaccess rules to point all traffic to the public directory automatically.

When Is This Needed?

Use this method if:

Step 1: Locate or Create the .htaccess File

  1. Log in to cPanel.

  2. Open File Manager.

  3. Navigate to your domain’s root directory (public_html).

  4. Enable Show Hidden Files (Dotfiles) from File Manager settings.

  5. Look for a file named .htaccess.

Step 2: Add Rewrite Rules

Open the .htaccess file and add the following code:

RewriteEngine On
RewriteRule ^(.*)$ public/$1 [L]

Save the file once done.

Step 3: Test Your Website

Important Notes

Need Help?

If your site shows errors after applying these changes, or if Laravel still does not load correctly, contact our support team for further guidance.