如何解决LiteSpeed服务器上找不到的PHP页面

我的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

jieqicheng 回答:如何解决LiteSpeed服务器上找不到的PHP页面

在您的来源中没有.htaccess,听起来好像缺少重定向。

您需要通过前端控制器index.php路由适当的URL。

使用Apache样式服务器,您可以使用modrewrite.htaccess文件。

首先,使用以下规则创建一个.htaccess-您可能需要根据自己的需要进行调整;

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-s
RewriteCond %{REQUEST_FILENAME} !-l
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^.*$ index.php [NC,L]

Webmasters Stackexchange复制的代码。

本文链接:https://www.f2er.com/2820818.html

大家都在问