【发布时间】:2020-01-04 11:38:32
【问题描述】:
我有一个 PHP 文件的以下布局
├── classes/
├── migrations/
├── public/
│ ├── images/
│ ├── scripts/
│ ├── styles/
│ └── index.php
├── sample/
└── templates/
我不知道如何将它放在我的服务器上,所以我将 public 中的文件放入了我的 public_html 文件夹(这是我的 cPanel 已经拥有的)。
另外,我把其他目录和public_html放在同一层级,以保持项目的正常结构。
因此,我最终得到了这个:
├── (some cPanel directory and files)
├── classes/
├── migrations/
├── public_html/
│ ├── images/
│ ├── scripts/
│ ├── styles/
│ └── index.php
├── sample/
├── templates/
└── (other cPanel directory and files)
现在,除索引页外,所有其他页面都返回 HTTP 状态代码 404。
我做错了什么?
作为参考,我正在尝试部署的项目位于https://github.com/srv-twry/Quizzer。
【问题讨论】:
-
您可以更改您网站的文档根目录吗?
-
将您的网站定位到example.com/index.php,这行得通吗?可以访问日志吗?放置在文档根目录中的任何 Php 文件是否按预期运行?
-
也许您需要使用 .htaccess 进行重定向并重写规则?假设这个服务器是 Apache。您在开发时如何运行您的网站?
-
它正在处理 index.php(因为它看起来正在使用您的代码),只是您的路由没有考虑 URL 中的 index.php。你所缺少的只是一些我认为的重写规则。
-
试试这样的:webmasters.stackexchange.com/a/57316/89012,但是看起来你正在运行一个 litespeed 服务器,所以配置可能会有所不同。检查手册和/或您的托管服务提供商。