Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

ShamiCanCode's avatar

Laravel upload on share hosting

can you please answer me how to upload laravel in shared hosting I uploaded with a method Create index.php file and redirect to the public folder but it shows something like this

www.xyz.com/public/

which looks so weird

0 likes
4 replies
LaryAI's avatar
LaryAI
AI
Best Answer
Level 58

You can use the .htaccess file to redirect requests to the public folder. To do this, create a .htaccess file in the root of your project and add the following code:

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

This will redirect all requests to the public folder. You can also add the following code to the public/.htaccess file to remove the public from the URL:

RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+public/([^\s]+) [NC]
RewriteRule ^ /%1 [R=301,L]

This should solve your issue.

webrobert's avatar

yep you need to point the website to the public folder of laravel not the root of the project.

For example, on my server I have a folder of sites..

site_one
site_two 
site_three

šŸ™ƒ you don't point the site to here site_one

Point it to site_one/public

Please or to participate in this conversation.