Block bots

This commit is contained in:
Bad Manners 2024-09-04 18:10:14 -03:00
parent 90fc60e871
commit 6cdd20eedc
No known key found for this signature in database
GPG key ID: 8C88292CCB075609
6 changed files with 110 additions and 2 deletions

View file

@ -3,6 +3,7 @@ import tailwindIntegration from "@astrojs/tailwind";
import markdownIntegration from "@astropub/md";
import htaccessIntegration from "astro-htaccess";
import pagefindIntegration from "astro-pagefind";
import { AI_BOTS } from "./src/data/ai_bots";
// https://astro.build/config
export default defineConfig({
@ -14,6 +15,15 @@ export default defineConfig({
markdownIntegration(),
htaccessIntegration({
generateHtaccessFile: import.meta.env.APACHE_CONFIG === "true",
customRules: [
// Block AI bots
"<IfModule mod_rewrite.c>",
" RewriteEngine on",
" RewriteBase /",
` RewriteCond %{HTTP_USER_AGENT} ${AI_BOTS.map((bot) => `^${bot}$`).join("|")} [NC]`,
" RewriteRule ^ [F]",
"</IfModule>",
],
redirects: [
{ match: "/story/", url: "/stories/" },
{ match: "/game/", url: "/games/" },