httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Joshua Slive <>
Subject Re: [users@httpd] Sending PHP-generated file Vs. plain text
Date Sun, 16 May 2004 14:12:16 GMT

On Sat, 15 May 2004, Joey Hewitt wrote:
>   The problem is it looks like Apache is recognizing the .txt file before it
> sees the .php file.  If I type the URL in my address bar with the .php on the
> end, it works, but if I don't include an extension, I get the text file.
>   If I can't find out how to make Apache recognize the .php file, I can move the
> text file out of the DocumentRoot and it will work fine for me.  (After all,
> does anyone set their browser to only Accept text/plain these days anyways? :)
> )
>   I realize that .php is a sort of generic extension in the sense that you can
> use PHP to serve any type of data.  Indeed, it seems Apache uses PHP as a
> "last-ditch attempt" to fulfill requests, because if I give it the same Accept
> parameters my browser does but without text/plain, it gives me the .php file
> like I want.  Because of this, it may not be possible to cleanly do what I
> want, so if not, I'll just give up on the text-only idea.  (It could also be
> implemented as a parameter passed to the PHP file through the URL, but that
> wouldn't be as automatic.  If it's not a convenient side-effect, I don't really
> care, because, again, no-one will probably only Accept text/plain anyways.)

I don't know of any browser that understands text/plain and not text/html,
so this is probably a silly idea.

But if you really want to do this, there are some notes which explain the
basic solution here:
(Essentially, you need to use AddHandler rather than AddType to activate
your php handler, and then use AddType to designate the php script as

But then you are going to run into the problem that most browsers don't
express a preference for text/html over text/plain anyway, so the
text/plain might end up getting served because it is smaller.  You could,
perhaps, use server-side quality values to fix this, but I don't really
know the details.


The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:> for more info.
To unsubscribe, e-mail:
   "   from the digest:
For additional commands, e-mail:

View raw message