26 lines
745 B
PHP
26 lines
745 B
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use Illuminate\Http\Response;
|
|
|
|
class RobotsController extends Controller
|
|
{
|
|
public function index(): Response
|
|
{
|
|
$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; charset=utf-8');
|
|
}
|
|
}
|