【问题标题】:Error 404 after migrating laravel 8 to a shared host将 laravel 8 迁移到共享主机后出现错误 404
【发布时间】:2021-03-16 00:33:37
【问题描述】:

大家好,我是 laravel 的新手,希望有人能帮助我解决我的问题。我创建了一个 laravel 项目。之后,我使用 softaculous 将其导入到 cpanel。然后,我根据我在网上研究的内容进行了一些更改,以避免显示像 .env 这样的重要文件。我创建了一个相对于 public_html 的文件夹,假设文件夹名称是“tamangbilang”,我将除 index.php 之外的几乎所有代码都放在其中。在我的 public_html 文件夹中,我有另一个名为“tamangbilang”的文件夹,我的 index.php 位于其中。我已经按照这个指令https://dev.to/pushpak1300/deploying-laravel7-app-on-shared-hosting-hostinger-31cj 唯一的区别是我在 public_html 中放了另一个文件夹。我还对 index.php 代码做了一些更改

require __DIR__.'/../../tamangbilang/vendor/autoload.php';
$app = require_once __DIR__.'/../../tamangbilang/bootstrap/app.php';

在我的登录页面(我的第一页)上一切正常,但是当我尝试登录时,出现错误。

The requested URL was not found on this server.
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.

似乎路线之间的连接丢失了。我做了进一步的测试,我注意到只有在 url 中的路由之前有 index.php 时,代码才能正常工作。例子

http://my-sample-domain.org/tamangbilang/index.php/login

附:我无权访问 ssh。

【问题讨论】:

  • 如果这适用于带有 Windows 的开发机器,请检查您的拼写
  • 如果有新日志,请在index.php旁边分享最后一行日志文件
  • 在我的 cpanel 中,我有终端,所以我可以像 ssh 一样通过 web 访问运行 php artisan

标签: php laravel migration shared-hosting softaculous


【解决方案1】:

转到引导文件夹并打开缓存文件夹,然后删除配置。之后请检查您的路线此错误基本上是由于找不到路线而出现的,请转到您在本地安装的项目并编写 php artisan route: list check if the route is present or not.

【讨论】:

  • 谢谢老兄,但我之前已经删除了这个文件。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2021-06-12
  • 1970-01-01
  • 2016-04-10
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-02-03
相关资源
最近更新 更多