我开发了 Laravel 11 网站。我有管理面板的子域,这是我的 paths/web.php 文件:
Route::domain('admin.domain')->name('admin.')->group( function () {
Route::get('/', 'index')->name('login.index');
Route::get('/login', 'index')->name('login.show');
});
在我的本地主机上一切正常,但是当我将项目上传到 cpanel 并输入 / 时,它按预期显示登录页面,但 /login 返回 404 not found 服务器错误,而不是 laravel 的 404。 这就是我将网站上传到 cpanel 的方式:
<?php
use Illuminate\Http\Request;
define('LARAVEL_START', microtime(true));
// Determine if the application is in maintenance mode...
if (file_exists($maintenance = __DIR__.'/../storage/framework/maintenance.php')) {
require $maintenance;
}
// Register the Composer autoloader...
require __DIR__.'/../vendor/autoload.php';
// Bootstrap Laravel and handle the request...
(require_once __DIR__.'/../bootstrap/app.php')
->handleRequest(Request::capture());
到
<?php
use Illuminate\Http\Request;
define('LARAVEL_START', microtime(true));
// Determine if the application is in maintenance mode...
if (file_exists($maintenance = __DIR__.'/../web_files/storage/framework/maintenance.php')) {
require $maintenance;
}
// Register the Composer autoloader...
require __DIR__.'/../web_files/vendor/autoload.php';
// Bootstrap Laravel and handle the request...
(require_once __DIR__.'/../web_files/bootstrap/app.php')
->handleRequest(Request::capture());
好吧,我找到了问题所在。 是因为我忘记上传.htaccess