3

By default, Laravel project is run from the public directory. For this, I must enter http://localhost/public/.

How do I configure Laravel so that the website will appear to be from http://localhost/?

apaderno
  • 28,547
  • 16
  • 75
  • 90
Dev
  • 1,013
  • 7
  • 15
  • 37
  • 2
    you can configure it with your web server. are you using nginx? For every domain, you also setup a root directory, which should be /dir/to/laravel/public instead of /dir/to/laravel – Bartu Aug 20 '16 at 17:42
  • If you're not using a web server you can also use `php -S localhost:80 -t public` from the root directory – Winter Aug 20 '16 at 17:58
  • I dont have access to command line also to nginx, it is simple hosting – Dev Aug 20 '16 at 17:59
  • You can rename file that will be find in root folder name with **server.php** . just rename in **index.php**. – pankaj Jan 14 '21 at 09:32
  • use this link for better understand. https://stackoverflow.com/questions/20547891/how-to-run-laravel-in-root-directory-without-the-public-folder/65716511#65716511 – pankaj Jan 14 '21 at 09:41

3 Answers3

15

•Go to mainproject/public>>

a.  .htacess
b.  favicon.ico
c.  index.php
d.  robots.txt
e.  web.config

1.cut these 5 files from the public folder, and then paste on the main project folder that’s means out side of public folder… mainproject/files

2.Next after paste ,open index.php ,modify

•require __DIR__.'/…/bootstrap/autoload.php';  to
•require __DIR__.'/bootstrap/autoload.php';
  1. modify

    $app = require_once DIR.'/../bootstrap/app.php'; to

    $app = require_once DIR.'/bootstrap/app.php';

you can also watch this video for better understanding----------------

https://www.youtube.com/watch?v=GboCYqEbKN0

Borna
  • 538
  • 4
  • 19
3

Setup your webserver (probably Apache or NginX) to use the public folder of your laravel app as root directory. Or use a public_html folder and symlink it to your public folder, which basically does the same.

Loek
  • 4,037
  • 19
  • 35
0

open your project in visual studio code

in new terminal type

php artisan serve

and goto http://127.0.0.1:8000

Merrin K
  • 1,602
  • 1
  • 16
  • 27