Support the ongoing development of Laravel.io →
Installation Authentication Database

I moved my index.php file to the root of my app. and rearranged the below two files

From this

require __DIR__.'/../bootstrap/autoload.php';

$app = require_once __DIR__.'/../bootstrap/start.php';

to this

require __DIR__.'/./bootstrap/autoload.php';

$app = require_once __DIR__.'/./bootstrap/start.php';

By doing the above step, this partly worked. Meaning, my website uploaded fine, the functionality worked but my CSS was out of place and my website lives within the "public" folder. In this "public" folder the website looks and works great but I don't want my website living within a folder.

My question is, how do I have my website display itself properly at the root level? and not live within the "public" folder.

Thanks

Last updated 2 years ago.
0

If I understood you correctly, I believe you're looking to remove the public segments from your application. Try the following steps.

Open the index.php file and change from:

require __DIR__.'/../bootstrap/autoload.php';

$app = require_once __DIR__.'/../bootstrap/start.php';

to:

require __DIR__.'/bootstrap/autoload.php';

$app = require_once __DIR__.'/bootstrap/start.php';

And also, open the paths.php file under the bootstrap folder, and then change from:

'public' => __DIR__.'/../public'

to:

'public' => __DIR__.'/..'

P.S. Don't forget to restart your Web server.

0

Try what rayeess suggested, however you should be using the public directory for your web files. Your document root in your virtual host should be set to the public folder for security reasons

0

T>tuyenlaptrinh said:

http://duytuyen.com/php/xoa-thu-muc-public-cua-laravel.html

May be help you

That might if it was in ENGLISH.. ;)

0

You can use translate of chrome or follow step by step in images

0
  • Create a new folder in the root of the project called laravel and move all files and folders into that directory EXCEPT the public folder.

  • Move /public files into root directory and delete the now empty public folder

  • Modify index.php

require __DIR__.'/../bootstrap/autoload.php';

Replace with

require __DIR__.'/laravel/bootstrap/autoload.php';
$app = require_once __DIR__.'/../bootstrap/start.php';

Replace with
	
$app = require_once __DIR__.'/laravel/bootstrap/start.php';
  • Modify laravel/bootstrap/paths.php
'public' => __DIR__.'/../public',

Replace with
	
'public' => __DIR__.'/../..',
0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.