parse .txt as php + output mime type as text/plain
Posted by: Denabral
Posted on: 2009-09-04 08:51:00
I'm trying to get plain text files parsed as .php files, but am not having much luck in also having that result returned as plain text to a browser via code.
Here is the setup so far within my DH acct :
cat .htaccess
RemoveHandler .txt .text
AddHandler php-cgi .txt .text
#<FilesMatch "\.(t?xt)$">
#AddType application/x-httpd-php .php .txt .text
#AddType application/php5-cgi .php .txt .text
#ForceType text/plain
#</FilesMatch>
and
head test.txt
<?php
header("Content-Type: text/plain");
?>
This is plain text to test.
However, when I try to set the content type within the top of the sample text file it does not seem to honor any of the header statements.
http://redbot.org/ shows this :
Content-Type: text/plain; charset=UTF-8
which looks great; it's even running through gzip properly, etc.
However, actually browsing to the file yields
<?php
header("Content-Type: text/plain");
?>
This is plain text to test.
which is obviously not quite what I'm looking for.
I wish to keep detailed track of a few specific text files in a folder that could potentially be directly downloaded directly by URL. I will have whatever .htaccess statements are needed specified at that folder level.
The stats track program is written in php5, and is called via include. This works fine as a footer at the end of my standard site files, which all end in .php
Thanks for any pointers! ![]()
responses to this thread will be emailed to me, thanks.