[英]Laravel 5.2 Avoiding public folder and open directly from root in localhost
The reason why I'm doing that is Laravel has the document root in a subdirectory is so that you don't have to expose your code to the public.
我这样做的原因是
Laravel has the document root in a subdirectory is so that you don't have to expose your code to the public.
The folder structure in my localhost is 我的本地主机中的文件夹结构是
Test
Test/laravel/
Test/public_html/
where laravel contains all the folder of root without the public folder and public_html contains the public files. 其中laravel包含root的所有文件夹,不包含公用文件夹,而public_html包含公用文件。
And I have changed in below lines in public_html/index.php
: 而且我在
public_html/index.php
以下public_html/index.php
行中进行了更改:
require __DIR__.'./../laravel/bootstrap/autoload.php';
$app = require_once __DIR__.'./../laravel/bootstrap/app.php';
I have followed the solution for solving the problem but couldn't solve it as I'm using 5.2. 我已遵循解决问题的解决方案 ,但由于使用5.2而无法解决。 If anyone has done this before please provide a valid solution.
如果有人这样做过,请提供有效的解决方案。
Thanks in advance. 提前致谢。
Laravel already comes with the public directory (which would be easily renamed public_html). Laravel已经带有公共目录(可以很容易地重命名为public_html)。 However, looking at your code, an issue lies at
**./**../laravel/bootstrap/autoload.php'
但是,查看您的代码,问题出在
**./**../laravel/bootstrap/autoload.php'
This would end up with a directory like Test./
instead of Test/
. 这将以
Test./
这样的目录代替Test/
。 Remove the period before the first slash. 删除第一个斜杠之前的句点。
require __DIR__.'/../laravel/bootstrap/autoload.php';
$app = require_once __DIR__.'/../laravel/bootstrap/app.php';
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.