如何在共享托管中将laravel项目指向public_html下的公共文件夹 [英] How to point laravel project to a public folder under public_html in shared hosting

查看:100
本文介绍了如何在共享托管中将laravel项目指向public_html下的公共文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  1. 我的共享托管帐户中有第二个域.
  2. 我的laravel项目在根目录中
  3. laravel公用文件夹位于public_html下. public_html/public

注意:我不希望公共文件直接位于 public_html 下,因为我还有其他文件会被覆盖.

Note: I don't want the public files directly under public_html because I have other files that would be overwritten.

我已经将这些更改为我的 index.php 文件中的行.

I've already changed these to lines in my index.php file.

需要 DIR .'/../../MyOtherDomain.com/vendor/autoload.php';

require DIR.'/../../MyOtherDomain.com/vendor/autoload.php';

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

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

问题是我如何指向laravel项目使用 public_html/public 下的 index.php 文件?

The question is how do i point the laravel project to use the index.php file under public_html/public?

谢谢.

推荐答案

由于使用共享托管,因此需要将域的文档根目录更改为public_html/public.然后,您需要通过编辑以下代码,将index.php指向您的Laravel项目(该项目只能位于public_html文件夹之外):

Since you're using shared hosting, you need to change the document root of the domain to public_html/public. Then you need to point index.php to your Laravel project (which must only be located outside the public_html folder) by editing the following code:

require DIR.'/../../MyOtherDomain.com/vendor/autoload.php';
$app = require_once DIR.'/../../MyOtherDomain.com/bootstrap/app.php';

注意:MyOtherDomain.com文件夹应包含Laravel项目.

Note- MyOtherDomain.com folder should contain the Laravel project.

这篇关于如何在共享托管中将laravel项目指向public_html下的公共文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆