llms.txt as a rewrite rule
The negative statements block is the most useful part: it is how you stop an engine conflating you with a similarly named product. The file costs one route. Check aeo-llms-txt
<?php
// No plugin ships this, so it is a rewrite rule plus a template redirect.
add_action('init', function () {
add_rewrite_rule('^llms\.txt$', 'index.php?llms_txt=1', 'top');
});
add_filter('query_vars', function ($vars) {
$vars[] = 'llms_txt';
return $vars;
});
add_action('template_redirect', function () {
if (!get_query_var('llms_txt')) {
return;
}
header('Content-Type: text/plain; charset=utf-8');
header('Cache-Control: public, max-age=3600, s-maxage=3600');
$lines = [
'# ' . get_bloginfo('name'),
'',
'> ' . get_bloginfo('description'),
'',
'## Key facts',
'',
'- Canonical site: ' . home_url(),
'',
'## What this is not',
'',
'- ' . get_bloginfo('name') . ' is not a marketplace.',
];
echo implode("\n", $lines) . "\n";
exit;
});