Thứ Sáu, 12 tháng 9, 2025

Laravel - Fix code chạy trong host DocumentRoot (public_html)

Đoạn code mặc định (L1)

declare(strict_types=1);

define('LARAVEL', microtime(true));

require __DIR__.'/../vendor/autoload.php';

$app = require_once __DIR__.'/../bootstrap/app.php';

$kernel = $app->make(Illuminate\Contracts\Http\Kernel::class);

$response = $kernel->handle(

    $request = Illuminate\Http\Request::capture()

);

$response->send();

$kernel->terminate($request, $response);


Thay bằng đoạn code (L2)

## freescout: tên folder ngang hàng public_html

// Trỏ đường dẫn đến thư mục "public" của FreeScout

$freescout_path = __DIR__ . '/../freescout/public';

// Nếu index gốc của FreeScout tồn tại thì include

if (file_exists($freescout_path . '/index.php')) {

    require $freescout_path . '/index.php';

} else {

    echo "Không tìm thấy FreeScout trong: " . htmlspecialchars($freescout_path);

}


**** Note:

--> phần public giữ nguyên và copy toàn bộ nội dung đó quá documentroot(public_html) 

--> chỉ thay đổi file file public_html/index.php giống (L2) 

Không có nhận xét nào:

Đăng nhận xét