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:
header("refresh: 5;");
echo '<title>Laravel Installed</title><div style="background: #e9ffed; border: 1px solid #b0dab7; padding: 15px;" align="center" >
<font size="5" color="#182e7a">Laravel is installed successfully.</font><br /><br />
<font size="4">Laravel is a Framework and doesn\'t have an index page.<br /><br />
You will be redirected to its "public" folder in 5 seconds...<br /><br />
Laravel is a clean and classy framework for PHP web development.
Freeing you from spaghetti code, Laravel helps you create wonderful applications using simple, expressive syntax. Development should be a creative experience that you enjoy, not something that is painful. Enjoy the fresh air.

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

<?phpuse Illuminate\Contracts\Http\Kernel;
use Illuminate\Http\Request;
define('LARAVEL_START', microtime(true));require __DIR__.'/vendor/autoload.php';$app = require_once __DIR__.'/bootstrap/app.php';$kernel = $app->make(Kernel::class);$response = tap($kernel->handle(
$request = Request::capture()
$kernel->terminate($request, $response);

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

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

How to get more sign ups with Firebase Authentication on Android

You probably have a bigger network than you think.

Working easily with FCM push notifications in Android

Strategy Pattern

How to mine Shiba Inu using your Laptop/Desktop


Data Structures & Advanced Algorithms in Rails Travel App

Serverless, Savvy, S-Lambda. Writing a 200-Oker using AWS Lambda

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Chigozie Orunta

Chigozie Orunta

Full Stack Engineer

More from Medium

How to Clone Laravel Project from Git Repository and Run it on Local Machine

Configure Authentication in Swagger UI for JWT in .Net Core Web API

Deploy a .NET web app on Amazon ECS

How to run feature tests in Laravel 9 in memory using SQLite