我有以下 PHP 文件的布局├── classes/├── migrations/├── public/│ ├── images/│ ├── scripts/│ ├── styles/│ └── index.php├── sample/└── templates/我不確定如何將它放在我的服務(wù)器上,所以我將文件從public我的public_html文件夾中(這是我的 cPanel 已經(jīng)擁有的)。此外,我將其他目錄放在同一級別,public_html以保持項目的正常結(jié)構(gòu)。因此,我最終得到了這個:├── (some cPanel directory and files)├── classes/├── migrations/├── public_html/│ ├── images/│ ├── scripts/│ ├── styles/│ └── index.php├── sample/├── templates/└── (other cPanel directory and files)現(xiàn)在,除索引頁面外,所有其他頁面都返回 HTTP 狀態(tài)代碼 404。我究竟做錯了什么?作為參考,我嘗試部署的項目可在https://github.com/srv-twry/Quizzer獲得。
1 回答

九州編程
TA貢獻1785條經(jīng)驗 獲得超4個贊
在您的源中沒有.htaccess,并且聽起來好像缺少重定向。
您需要通過前端控制器路由適當?shù)?URL - index.php.
使用 Apache 風格的服務(wù)器,您可以使用modrewrite一個.htaccess文件。
作為起點,.htaccess使用以下規(guī)則創(chuàng)建一個 - 您可能需要根據(jù)您的個人需求進行調(diào)整;
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-s
RewriteCond %{REQUEST_FILENAME} !-l
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^.*$ index.php [NC,L]
從網(wǎng)站管理員 Stackexchange復制的代碼。
- 1 回答
- 0 關(guān)注
- 75 瀏覽
添加回答
舉報
0/150
提交
取消