Skip to content

Commit 7a76c56

Browse files
authored
Merge pull request #165 from tomsl123/main
2 parents d252e69 + e706e87 commit 7a76c56

File tree

1 file changed

+85
-6
lines changed

1 file changed

+85
-6
lines changed

config/routes.php

Lines changed: 85 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
return [
99
[
1010
'pattern' => 'robots.txt',
11-
'action' => function () {
11+
'method' => 'GET|HEAD',
12+
'action' => function () {
1213
if (Seo::option('robots.active')) {
1314
$content = snippet('seo/robots.txt', [], true);
1415
return new Response($content, 'text/plain', 200);
@@ -17,19 +18,51 @@
1718
$this->next();
1819
}
1920
],
21+
[
22+
'pattern' => 'robots.txt',
23+
'method' => 'OPTIONS',
24+
'action' => function () {
25+
return new Response('', 'text/plain', 204, ['Allow' => 'GET, HEAD']);
26+
}
27+
],
28+
[
29+
'pattern' => 'robots.txt',
30+
'method' => 'ALL',
31+
'action' => function () {
32+
return new Response('Method Not Allowed', 'text/plain', 405, ['Allow' => 'GET, HEAD']);
33+
}
34+
],
35+
2036
[
2137
'pattern' => 'sitemap',
22-
'action' => function () {
38+
'method' => 'GET|HEAD',
39+
'action' => function () {
2340
if (!Seo::option('sitemap.redirect') || !Seo::option('sitemap.active')) {
2441
$this->next();
2542
}
2643

2744
go('/sitemap.xml');
2845
}
2946
],
47+
[
48+
'pattern' => 'sitemap',
49+
'method' => 'OPTIONS',
50+
'action' => function () {
51+
return new Response('', 'text/plain', 204, ['Allow' => 'GET, HEAD']);
52+
}
53+
],
54+
[
55+
'pattern' => 'sitemap',
56+
'method' => 'ALL',
57+
'action' => function () {
58+
return new Response('Method Not Allowed', 'text/plain', 405, ['Allow' => 'GET, HEAD']);
59+
}
60+
],
61+
3062
[
3163
'pattern' => 'sitemap.xsl',
32-
'action' => function () {
64+
'method' => 'GET',
65+
'action' => function () {
3366
if (!Seo::option('sitemap.active')) {
3467
$this->next();
3568
}
@@ -49,9 +82,25 @@
4982
])->render(contentType: 'xsl');
5083
}
5184
],
85+
[
86+
'pattern' => 'sitemap.xsl',
87+
'method' => 'OPTIONS',
88+
'action' => function () {
89+
return new Response('', 'text/plain', 204, ['Allow' => 'GET']);
90+
}
91+
],
92+
[
93+
'pattern' => 'sitemap.xsl',
94+
'method' => 'ALL',
95+
'action' => function () {
96+
return new Response('Method Not Allowed', 'text/plain', 405, ['Allow' => 'GET']);
97+
}
98+
],
99+
52100
[
53101
'pattern' => 'sitemap.xml',
54-
'action' => function () {
102+
'method' => 'GET|HEAD',
103+
'action' => function () {
55104
if (!Seo::option('sitemap.active', true)) {
56105
$this->next();
57106
}
@@ -69,9 +118,25 @@
69118
])->render(contentType: 'xml');
70119
}
71120
],
121+
[
122+
'pattern' => 'sitemap.xml',
123+
'method' => 'OPTIONS',
124+
'action' => function () {
125+
return new Response('', 'text/plain', 204, ['Allow' => 'GET, HEAD']);
126+
}
127+
],
128+
[
129+
'pattern' => 'sitemap.xml',
130+
'method' => 'ALL',
131+
'action' => function () {
132+
return new Response('Method Not Allowed', 'text/plain', 405, ['Allow' => 'GET, HEAD']);
133+
}
134+
],
135+
72136
[
73137
'pattern' => 'sitemap-(:any).xml',
74-
'action' => function (string $index) {
138+
'method' => 'GET|HEAD',
139+
'action' => function (string $index) {
75140
if (!Seo::option('sitemap.active', true)) {
76141
$this->next();
77142
}
@@ -92,5 +157,19 @@
92157
],
93158
])->render(contentType: 'xml');
94159
}
95-
]
160+
],
161+
[
162+
'pattern' => 'sitemap-(:any).xml',
163+
'method' => 'OPTIONS',
164+
'action' => function () {
165+
return new Response('', 'text/plain', 204, ['Allow' => 'GET, HEAD']);
166+
}
167+
],
168+
[
169+
'pattern' => 'sitemap-(:any).xml',
170+
'method' => 'ALL',
171+
'action' => function () {
172+
return new Response('Method Not Allowed', 'text/plain', 405, ['Allow' => 'GET, HEAD']);
173+
}
174+
],
96175
];

0 commit comments

Comments
 (0)