Fix public directory access of Laravel in cpanel

 Create a .htaccess file inside the root directory. same level as the laravel .env file. 

and paste the below code:

DirectoryIndex index.php
RewriteEngine On
RewriteRule ^$ public/index.php [L]
RewriteRule ^((?!public/).*)$ public/$1 [L,NC]


Other Searching terms:
laravel public folder htaccess
.htaccess on root directory to redirect to public folder
.htaccess Accessing from public_html
Setup an .htaccess file for redirecting to Laravel’s public folder

Comments