How to run Laravel from root directory, not from public?

邮差的信 提交于 2019-12-18 03:49:07

问题


By default, Laravel project is run from public directory, for this I must enter URL like as:

http://localhost/public/

How to configure Laravel that website will be appeared from: http://localhost/?


回答1:


•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




回答2:


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.



来源:https://stackoverflow.com/questions/39057011/how-to-run-laravel-from-root-directory-not-from-public

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!