diff --git a/src/.htaccess.njk b/src/.htaccess.njk index 2b3e8d69..febf04ab 100644 --- a/src/.htaccess.njk +++ b/src/.htaccess.njk @@ -15,7 +15,5 @@ Header set Cache-Control "no-cache, public" RewriteEngine on # Block bad bots -{% for bot in robots.htaccess -%} -RewriteCond %{HTTP_USER_AGENT} ({{ bot | replace(" ", ".*") }}) [NC{% if not loop.last %},OR{% endif %}] -{% endfor -%} +RewriteCond %{HTTP_USER_AGENT} ({{ robots.htaccess }}) [NC] RewriteRule .* https://nocommercialuse.org/ [L] \ No newline at end of file diff --git a/src/_data/robots.js b/src/_data/robots.js index 30cfd807..2ab051c6 100644 --- a/src/_data/robots.js +++ b/src/_data/robots.js @@ -23,10 +23,10 @@ export default async function () { line !== "User-agent: Applebot" ); }) - .map((line) => line.split(":")[1].trim()); + .map((line) => line.split(":")[1].trim().replace(/\s/gi, ".*")); return { txt: txt, - htaccess: bots, + htaccess: bots.join('|'), }; } \ No newline at end of file