php - 如何解决在 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获得。
解决方案
在您的源中没有.htaccess
,并且听起来好像缺少重定向。
您需要通过前端控制器路由适当的 URL - index.php
.
使用 Apache 风格的服务器,您可以使用modrewrite
一个.htaccess
文件。
作为起点,.htaccess
使用以下规则创建一个 - 您可能需要根据您的个人需求进行调整;
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-s
RewriteCond %{REQUEST_FILENAME} !-l
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^.*$ index.php [NC,L]
从网站管理员 Stackexchange复制的代码。
推荐阅读
- sql - 将表条目从一个数据库传输到另一个数据库
- python - 总结字典内列表中相同键的值?
- javascript - JS画布显示在页面底部
- google-apps-script - 谷歌表覆盖现有数据库
- leaflet - 打开街道地图默认图块(传单)
- javascript - React - 在同一选项卡中打开一个链接,然后单击新链接中的一个按钮
- c# - EF Core await ToArrayAsync() 在 DbContext 中不起作用
- python - 在 azure webjobs 中的多个文件中运行一个文件
- google-sheets - 如何解决在任何情况下出现的“禁用登录”?
- java - 初始 java 下载是否必须与我下载的后续 jdks 位于同一文件中?