Use for loop to generate rewrite conditions for commercial AI bots

This commit is contained in:
Helen Chong 2024-08-21 02:17:28 +08:00
parent 3d1d3d4da4
commit 0030302d64
2 changed files with 4 additions and 2 deletions

View File

@ -14,5 +14,7 @@ Header set Cache-Control "no-cache, public"
RewriteEngine on
# Block bad bots
RewriteCond %{HTTP_USER_AGENT} {{ robots.htaccess }} [NC]
{% for bot in robots.htaccess -%}
RewriteCond %{HTTP_USER_AGENT} ({{ bot }}) [NC{% if not loop.last %},OR{% endif %}]
{% endfor -%}
RewriteRule .* https://nocommercialuse.org/ [L]

View File

@ -27,6 +27,6 @@ export default async function () {
return {
txt: txt,
htaccess: bots.join("|"),
htaccess: bots,
};
}