Skip to content

Commit 2752eed

Browse files
committed
Dynamic robots.txt so only www gets indexed
1 parent 66e9a46 commit 2752eed

File tree

2 files changed

+26
-13
lines changed

2 files changed

+26
-13
lines changed

public/robots.txt

Lines changed: 0 additions & 13 deletions
This file was deleted.

src/app/robots.txt/route.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
export async function GET(request: Request) {
2+
3+
let robotsTxt = `#
4+
# robots.txt - not running on www yet, so don't index anything
5+
#
6+
User-agent: *
7+
Disallow: /
8+
`;
9+
10+
if (request.headers.get("Host") === "www.regexplanet.com") {
11+
robotsTxt = `#
12+
# almost empty: everything at RegexPlanet is indexable!
13+
#
14+
Sitemap: https://www.regexplanet.com/sitemap.xml
15+
16+
User-agent: *
17+
Disallow: /honeypot.txt
18+
`
19+
}
20+
21+
return new Response(robotsTxt, {
22+
headers: {
23+
"Content-Type": "text/plain; charset=utf-8",
24+
},
25+
});
26+
}

0 commit comments

Comments
 (0)