-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
40 lines (36 loc) · 1.06 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?php
declare(strict_types=1);
@include_once __DIR__.'/vendor/autoload.php';
Kirby::plugin('bnomei/robots-txt', [
'options' => [
'content' => null,
'sitemap' => null,
'groups' => [
'*' => [ // user-agent
'disallow' => [
'/kirby/',
'/site/',
'/cdn-cgi/', // cloudflare. https://developers.cloudflare.com/fundamentals/get-started/reference/cdn-cgi-endpoint/
],
'allow' => [
'/media/',
],
],
],
],
'routes' => [
[
'pattern' => 'robots.txt',
'method' => 'GET',
'action' => function () {
$txt = (new \Bnomei\Robotstxt)->toTxt();
if ($txt) {
return new \Kirby\Http\Response($txt, 'text/plain', 200);
}
return kirby()->site()->visit(
kirby()->site()->errorPage() ?? 'error'
);
},
],
],
]);