![](/img/trans.png)
[英]How to remove trailing subfolder/public/index.php from the Laravel 9 website URL on shared hosting?
[英]Install laravel in shared hosting website's subfolder
我试图在我的共享托管网站的(不是laravel)子文件夹中安装Laravel。 例如在:example.com/dev
结构体:
->laravel
->app
->bootstrap
->public_html
...example.com folders & files
->dev
->css
->js
->.htacess
->index.php
... other Laravel public files
我的example.com/dev/index.php看起来像这样:
... laravel codes
/*
|--------------------------------------------------------------------------
| Register The Auto Loader
|--------------------------------------------------------------------------
|
| Composer provides a convenient, automatically generated class loader for
| our application. We just need to utilize it! We'll simply require it
| into the script here so that we don't have to worry about manual
| loading any of our classes later on. It feels great to relax.
|
*/
require __DIR__.'/../../laravel/bootstrap/autoload.php';
/*
|--------------------------------------------------------------------------
| Turn On The Lights
|--------------------------------------------------------------------------
|
| We need to illuminate PHP development, so let us turn on the lights.
| This bootstraps the framework and gets it ready for use, then it
| will load up this application so that we can run it and send
| the responses back to the browser and delight our users.
|
*/
$app = require_once __DIR__.'/../../laravel/bootstrap/app.php';
... laravel codes
问题:当我尝试输入http://example.com/dev/时,浏览器抛出错误:
此页面无效
mysite.com没有发送任何数据。
ERR_EMPTY_RESPONSE
互联网上没有此问题的任何信息/解决方案。
任何解决方案?
您的整个项目应在您的public_html
文件夹中。 然后将公用文件夹的所有内容也移到public_html
。 然后编辑index.php以匹配autoload.php
和app.php
的正确目录
根据您的文字,我假设您想通过http://example.com/dev/致电Laravel。如果您的托管人允许符号链接,您可以尝试一下。
-> laravel
-> app
-> ...
-> public // symlinked to public_html/example.com/dev
-> ...
-> public_html
-> example.com folders & files
-> dev // This is a symlink to laravel/public
在我看来,更好的方法是创建一个子域,然后将Laravel称为http://dev.example.com 。 这取决于您的托管者如何执行此操作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.