From 0792297bb8164fd2929b939d8d1206bc77b4ee81 Mon Sep 17 00:00:00 2001 From: hellcat Date: Sat, 12 Sep 2026 18:30:38 +0800 Subject: [PATCH] no message --- app/Http/Controllers/RobotsController.php | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/app/Http/Controllers/RobotsController.php b/app/Http/Controllers/RobotsController.php index 07c99c8b..51aae16a 100644 --- a/app/Http/Controllers/RobotsController.php +++ b/app/Http/Controllers/RobotsController.php @@ -8,19 +8,18 @@ class RobotsController extends Controller { public function index(): Response { - $sContent = implode("\n", [ - 'User-agent: *', - 'Allow: /', - 'Disallow: /admin/', - 'Disallow: /api/', - 'Disallow: /storage/', - 'Disallow: /vendor/', - 'Disallow: /test/', - 'Disallow: /*?*', - 'Sitemap: ' . config('app.url') . '/sitemap.xml', - ]); + $sContent = "User-agent: *\n"; + $sContent .= "Allow: /\n"; + $sContent .= "Disallow: /admin/\n"; + $sContent .= "Disallow: /api/\n"; + $sContent .= "Disallow: /storage/\n"; + $sContent .= "Disallow: /vendor/\n"; + $sContent .= "Disallow: /test/\n"; + $sContent .= "Disallow: /*?*\n\n"; + $sContent .= "Sitemap: " . config('app.url') . "/sitemap.xml\n"; + // 核心修复:强制指定 text/plain 响应头 return response($sContent, 200) - ->header('Content-Type', 'text/plain'); + ->header('Content-Type', 'text/plain; charset=utf-8'); } }