httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Joey Hewitt <j...@joeyhewitt.com>
Subject [users@httpd] Sending PHP-generated file Vs. plain text
Date Sun, 16 May 2004 03:16:58 GMT
Hello all,

  I've set up my site to use the Smarty template engine
(http://smarty.php.net/).  I extended the Smarty class and added a method to
populate the templates with information from a text file in the form of ("key:
value\nkey2: value2"...).  I even got it to work with arrays, and it's working
pretty slick for me.  But I'd like clients to be able to request a document
without an extension, and then have the server decide what file type to serve
based on their Accept parameters, because it seems like The Right Thing to
Do(TM), and, well, I'm kind of pedantic and purist like that ;).  So, I have
the text file sitting in the DocumentRoot along with the .php file which just
includes my Smarty class and calls the populate method with the path of the
text file.
  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.)

Thanks,
==Joey

----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Mime
View raw message