llms.txt file (for AI)

4 posts by 4 authors in: Forums > CMS Builder
Last Post: 8 hours ago   (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

By Codee - Saturday at 7:30pm - edited: Saturday at 7:31pm

Are you saying this little bit of code will generate all the llms.txt content for a site run by cmsb?  I am hoping there is a method for doing so. I figured a plugin might be needed.

Hi Codee,

The above is just a snippet that helps set up a PHP file that will load when "llms.txt" is accessed. On its own it does not generate any of the content, but it's a good first step in being able to do so.

Lucia
Technical Lead
interactivetools.com