Skip to content

Commit

Permalink
Use for loop to generate commercial AI bot list
Browse files Browse the repository at this point in the history
  • Loading branch information
helenclx committed Aug 20, 2024
1 parent 5631940 commit 0edf584
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/.htaccess.njk
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,7 @@ RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.*)/?$ /$1.php [L]

# 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]
2 changes: 1 addition & 1 deletion src/_data/robots.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ export default async function () {

return {
txt: txt,
htaccess: bots.join("|"),
htaccess: bots,
};
}

0 comments on commit 0edf584

Please sign in to comment.