Skip to content

Commit

Permalink
Dynamic robots.txt so only www gets indexed
Browse files Browse the repository at this point in the history
  • Loading branch information
fileformat committed Sep 25, 2024
1 parent 66e9a46 commit 2752eed
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 13 deletions.
13 changes: 0 additions & 13 deletions public/robots.txt

This file was deleted.

26 changes: 26 additions & 0 deletions src/app/robots.txt/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
export async function GET(request: Request) {

let robotsTxt = `#
# robots.txt - not running on www yet, so don't index anything
#
User-agent: *
Disallow: /
`;

if (request.headers.get("Host") === "www.regexplanet.com") {
robotsTxt = `#
# almost empty: everything at RegexPlanet is indexable!
#
Sitemap: https://www.regexplanet.com/sitemap.xml
User-agent: *
Disallow: /honeypot.txt
`
}

return new Response(robotsTxt, {
headers: {
"Content-Type": "text/plain; charset=utf-8",
},
});
}

0 comments on commit 2752eed

Please sign in to comment.