隱藏 public路徑後,網址出現錯誤
.運行 localhost/zaz//: <> (这里是注释,不会被渲染。可随意删除,以预览显示的内容为准。)
1. 运行环境
apache2.4.63
php8.3.16
mysql9.2
windows 10
1). 当前使用的 Laravel 版本?
version 12.x
2. 问题描述?
1.使用
composer create-project laravel/laravel zaz
在localhost建立laravel專案
2.我希望把專案的根目錄從zaz/public遷移到zaz,作了以下的動作
把public的index.php與.htaccess剪下來到zaz資料夾貼上,修改index.php為
<?php
use Illuminate\Foundation\Application;
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...
/** @var Application $app */
$app = require_once __DIR__.'/bootstrap/app.php';
$app->handleRequest(Request::capture());
3.運行 localhost/zaz 正確
4.我在public建立a1/index.php,
<?php
echo "這是史努比的家";
?>
5.打上localhost/zaz/a1,卻顯示404找不到網頁;我想要localhost/zaz/a1 等價於localhost/zaz/public/a1,可是結果不如預期,不知道如何除錯, 來向大家請教解法。
推荐文章: