Deploy Laravel to Shared hosting and upload files to public_html

Published on Aug 10, 2022

In my previous blog post we talked about how to change the public folder to public_html. In this post, I will show you how can you stick with the original public_html folder.

First, upload all your files to the public_html folder. Then add a new .htaccess file to it and add the following code.

RewriteEngine On
Options +FollowSymlinks
RewriteBase /

RewriteCond %{HTTP_HOST} ^.*$
RewriteCond %{REQUEST_URI} !public/
RewriteRule ^(.*)$ public/$1 [L]

This code will "redirect" the incoming request to the public folder.