Serve Markdown to AI crawlers from static HTML pages with a few .htaccess lines
A developer published a set of Apache .htaccess rules that serve a Markdown version of each static HTML page to known AI crawlers (GPTBot, ClaudeBot, PerplexityBot, CCBot and others) or to any client sending an Accept: text/markdown header, while browsers and Googlebot continue to receive HTML. The setup adds a text/markdown MIME type, a Vary header on Accept and User-Agent for correct caching, and a rel="alternate" discovery link in the page head, with curl commands for verifying bot, browser and content-negotiation responses. The developer notes that actual AI-assistant usage of the Markdown files is not yet measurable, and that stale caching caused a query-string bug during testing.
AI assistants read web pages, and HTML is a noisy format for them: navigation, scripts, styles and cookie banners around a few paragraphs of content. A Markdown version of the same page is cheaper to read and easier to quote. I added one to the static pages of my site and it took a handful of Apache rules. Here is the setup, with the mistakes I made. Disclosure: the pages I used this on belong to my app, Teleprompter Offline & Private, and I also build a WordPress plugin that does the same job for WordPress. The idea For every page /some-page/index.html , put a file /some-page/index.md next to it with the same content. Then serve the Markdown file when the request comes from a known AI crawler or when the client asks for it with an Accept: text/markdown header. Everyone else, browsers and Googlebot included, keeps getting the HTML. The rules AddType "text/markdown; charset=utf-8" .md RewriteEngine On RewriteCond %{REQUEST URI} /$ RewriteCond %{DOCUMENT ROOT}%{REQUEST URI}index.md -f RewriteCond %{HTTP ACCEPT} text/markdown NC,OR RewriteCond %{HTTP USER AGENT} GPTBot|ChatGPT-User|OAI-SearchBot|ClaudeBot|Claude-User|PerplexityBot|CCBot|Bytespider NC RewriteRule ^ . $ $1index.md E=MDPAGE:1,L Header append Vary "Accept, User-Agent" env=MDPAGE Three details matter: index.md are touched. Pages without one are served as usual. Vary header. Accept and User-Agent . Without NC,OR . I also added a discovery link in the page head, so crawlers that read HTML can find the Markdown: