llms.txt file (for AI)

2 posts by 2 authors in: Forums > CMS Builder
Last Post: November 6   (RSS)

Hi Jesus, 

Yes, you can use .htaccess and mod_rewrite to tell your web server to use a PHP file to generate the response.  Here's an example:

<?php
declare(strict_types=1);

/**
 * /llms.txt Generator
 *
 * Dynamically generates /llms.txt responses in Markdown format (text/plain).
 * See: https://llmstxt.org/
 *
 * To enable, add to .htaccess:
 *     <IfModule mod_rewrite.c>
 *         RewriteEngine On
 *         RewriteRule ^llms\.txt$ llms.txt.php [L]
 *     </IfModule>
 */

header('Content-Type: text/plain; charset=utf-8');

// Add your llms.txt content here (Markdown format)
echo "Hello from PHP\n";

Just save that as llms.txt.php, add the code to your .htaccess file, and then request /llms.txt in the browser to test.

Hope that helps! Let me know if you have any other questions.

Dave Edis - Senior Developer
interactivetools.com