如何解决在 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获得。


MMTTMM
浏览 70回答 1
1回答

九州编程

在您的源中没有.htaccess,并且听起来好像缺少重定向。您需要通过前端控制器路由适当的 URL - index.php.使用 Apache 风格的服务器,您可以使用modrewrite一个.htaccess文件。作为起点,.htaccess使用以下规则创建一个 - 您可能需要根据您的个人需求进行调整;RewriteEngine OnRewriteCond %{REQUEST_FILENAME} !-sRewriteCond %{REQUEST_FILENAME} !-lRewriteCond %{REQUEST_FILENAME} !-dRewriteRule ^.*$ index.php [NC,L]从网站管理员 Stackexchange复制的代码。
打开App,查看更多内容
随时随地看视频慕课网APP