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

eijinaal's avatar

Laravel website hosting on live

Hello All,

I have a query regarding laravel website hosting.

when i download the laravel using composer and run php artisan serve command my website start working with given URL without any changes.

But when i upload same folder on live website it is not working without /public

For Eg,

On Localhost : http://127.0.0.1:8000/login

On Live : http://domain.com/public/login

In both case my folder is same.

How can we solve this problem. Is there any way to make laravel website working on live without changing it's folder structure ?

0 likes
4 replies
Sonnenbrot's avatar

You have to set the document root in your web server's configuration file to point to the /public directory. In apache this is usually done in the vhosts config file.

1 like
eijinaal's avatar

I did same you guys advised. What i did i kept all the file of my public folder in a main project folder say folder1 and rest of the files in another folder say folder2. I set the path in index.php as below

require DIR.'/../folder2/bootstrap/autoload.php'; $app = require_once DIR.'/../folder2/bootstrap/app.php';

Now what happen when i try to upload any image or document in my public directory using public_path() method it is taking path of folder2. I am not sure but this might be a problem while fetching images. Suppose when i fetch any image using www.domain.com/userfiles/images/abc.png then Would it be fetch or not ?

Please or to participate in this conversation.