no message
This commit is contained in:
1 parent
5d85fb8bc3
commit
a82f234853
6 files changed
+112
-2
No files matched your search
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Response;
|
||||
|
||||
class RobotsController extends Controller
|
||||
{
|
||||
public function index(): Response
|
||||
{
|
||||
// $sContent 保存 robots.txt 的具体规则
|
||||
$sContent = implode("\n", [
|
||||
'User-agent: *',
|
||||
'Allow: /',
|
||||
'',
|
||||
'# 屏蔽 Laravel 系统路径',
|
||||
'Disallow: /admin/',
|
||||
'Disallow: /api/',
|
||||
'Disallow: /storage/',
|
||||
'Disallow: /vendor/',
|
||||
'Disallow: /*?*', // 屏蔽带参数的重复 URL,防止稀释权重',
|
||||
'',
|
||||
'# 声明 Sitemap 绝对路径(请替换为你的实际域名)',
|
||||
'Sitemap: ' . config('app.url') . '/sitemap.xml',
|
||||
]);
|
||||
|
||||
return response($sContent, 200)
|
||||
->header('Content-Type', 'text/plain');
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user