Skip to content
PHP Logo

How can Apache be configured to parse .txt files as PHP files for serving dynamic robots.txt content?

To configure Apache to parse .txt files as PHP files for serving dynamic robots.txt content, you can use the AddType directive in your Apache configuration file. This directive tells Apache to treat files with a specific extension as a certain MIME type, in this case, text/html for PHP files. By adding this directive, Apache will interpret .txt files as PHP files and execute any PHP code within them. ``` <FilesMatch "\.txt$"> SetHandler application/x-httpd-php </FilesMatch> ```