我有以下 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獲得。
1 回答

九州編程
TA貢獻1785條經驗 獲得超4個贊
在您的源中沒有.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復制的代碼。
- 1 回答
- 0 關注
- 78 瀏覽
添加回答
舉報
0/150
提交
取消