Fixing Laravel’s Public Folder Redirect on Cpanel Shared Hosting Installation

Getting the default home page for Laravel to come up as shown above for a Laravel installation on a Cpanel shared hosting might be surprisingly difficult.

This is because the default installation that comes with Cpanel’s Softaculous Laravel package ships with an index.php file that redirects you to the public folder rather than the root folder of your Laravel installation.

For a newly installed Laravel package using Softaculous, you typically see the following screen by default:

This screen after 5 seconds redirects to the public folder within your Laravel application. Obviously, this is not what we want, so let’s fix it in 2 easy steps!

  1. Locate the index.php file installed in your root folder by default. It should look similar to this:

2. Replace the contents of this file with the following script shown below:

Once done, save your index.php file and run your Laravel application again. This time it should point directly to your Laravel home page as expected.

And that’s it, you’re good to go!

Full Stack Engineer