如何从根目录而不是公共目录运行 Laravel?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/39057011/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to run Laravel from root directory, not from public?
提问by Dev
By default, Laravel project is run from public directory, for this I must enter URL like as:
默认情况下,Laravel 项目是从公共目录运行的,为此我必须输入如下 URL:
http://localhost/public/
How to configure Laravel that website will be appeared from: http://localhost/
?
如何配置 Laravel 网站将从以下位置出现:http://localhost/
?
回答by Borna
?Go to mainproject/public>>
?转到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
1.从公用文件夹中剪切这5个文件,然后粘贴到主项目文件夹中,即公用文件夹之外的... mainproject/files
2.Next after paste ,open index.php ,modify
2.下一步粘贴后,打开index.php,修改
?require __DIR__.'/…/bootstrap/autoload.php'; to
?require __DIR__.'/bootstrap/autoload.php';
modify
$app = require_once DIR.'/../bootstrap/app.php'; to
$app = require_once DIR.'/bootstrap/app.php';
调整
$app = require_once DIR.'/../bootstrap/app.php'; 到
$app = require_once DIR.'/bootstrap/app.php';
you can also watch this video for better understanding----------------
您也可以观看此视频以更好地理解----------------
回答by Loek
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.
设置您的网络服务器(可能是 Apache 或 NginX)以使用 Laravel 应用程序的公共文件夹作为根目录。或者使用一个public_html
文件夹并将其符号链接到您的公共文件夹,这基本上是相同的。