You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Kent Larsson <ke...@gmail.com> on 2008/01/25 06:59:40 UTC
[users@httpd] Dynamic text-file created by PHP
Hi,
I want to create a dynamic textfile using PHP for each request of it. If the
users asks for http://server/textfile.txt I want a PHP-script to execute and
serve the textual data completely transparent to the user. This is a "single
case" so associating all txt-files with PHP is not what I would like to do.
Which method would be the cleanest to use in this case? It's not a complex
rewrite.
Best regards,
Kent
Re: [users@httpd] Dynamic text-file created by PHP
Posted by Matus UHLAR - fantomas <uh...@fantomas.sk>.
> > > > you can make the .txt a php script and force pargins by php parser
> > > > by using <Files> and SetHandler
> > > > On 25.01.08 06:59, Kent Larsson wrote:
> > > Thank you! But I still don't get it to work.
> >
> > > <Files "txtfilefromphp.txt">
> > > SetType application/x-httpd-php
> > > </Files>
> > Tried SetHandler as suggested?
On 27.01.08 02:11, Kent Larsson wrote:
> Yes, sorry about the typo in my last post. It was SetHandler I meant.
> Still I am having one problem.
do you mean, that the parsing by PHP works already and you see only
php-generated content?
> I want the http response to look
> _exactly_ as when retriving a normal text file. I changed expose_php
> to no which got rid of one unwanted header. But still there are
> differences:
i guess those differencies are added by PHP - you can search for PHP
settings there or add own headers. But that's imho subject of PHP support
forum, not this one. But it only applies when the PHP is parsed and
executed, not when you see the text file.
> Response Headers
> Date Sun, 27 Jan 2008 01:05:15 GMT
> Server Apache
> Last-Modified Thu, 24 Jan 2008 19:33:03 GMT
> Etag "a40158-1a-e90699c0"
> Accept-Ranges bytes
> Content-Length 26
> Content-Type text/plain; charset=UTF-8
> = My php generated text file =
> Response Headers
> Date Sun, 27 Jan 2008 01:05:17 GMT
> Server Apache
> Keep-Alive timeout=15, max=97
> Content-Length 26
> Connection Keep-Alive
> Content-Type text/plain; charset=UTF-8
>
> I can easily add the missing headers to the php generated text file.
> But I don't want "Connection: Keep-Alive" or "Keep-Alive: timeout=15,
> max=97" sent. That's my main problem at the moment. Any ideas on how
> to not send those? Or how to "filter them out" using PHP?
>
> Someone said I could use mod_rewrite to get an exact response which is
> identical to the static normal text file from my php generated one.
> But I don't know how to do that using mod_rewrite. Any ideas on that
> approach?
I'm not sure if mod_rewrite allows you do that. It allows you e.g. to run
file.php when you request for file.txt but the headers should stay the same
PHP generated. But I'm not rewrite expert.
--
Matus UHLAR - fantomas, uhlar@fantomas.sk ; http://www.fantomas.sk/
Warning: I wish NOT to receive e-mail advertising to this address.
Varovanie: na tuto adresu chcem NEDOSTAVAT akukolvek reklamnu postu.
My mind is like a steel trap - rusty and illegal in 37 states.
---------------------------------------------------------------------
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
Re: [users@httpd] Dynamic text-file created by PHP
Posted by Kent Larsson <ke...@gmail.com>.
> > > On 25.01.08 06:59, Kent Larsson wrote:
> > > you can make the .txt a php script and force pargins by php parser by using
> > > <Files> and SetHandler
> >
> > Thank you! But I still don't get it to work.
>
> > <Files "txtfilefromphp.txt">
> > SetType application/x-httpd-php
> > </Files>
>
>
> Tried SetHandler as suggested?
Yes, sorry about the typo in my last post. It was SetHandler I meant.
Still I am having one problem. I want the http response to look
_exactly_ as when retriving a normal text file. I changed expose_php
to no which got rid of one unwanted header. But still there are
differences:
= A real text file =
Response Headers
Date Sun, 27 Jan 2008 01:05:15 GMT
Server Apache
Last-Modified Thu, 24 Jan 2008 19:33:03 GMT
Etag "a40158-1a-e90699c0"
Accept-Ranges bytes
Content-Length 26
Content-Type text/plain; charset=UTF-8
= My php generated text file =
Response Headers
Date Sun, 27 Jan 2008 01:05:17 GMT
Server Apache
Keep-Alive timeout=15, max=97
Content-Length 26
Connection Keep-Alive
Content-Type text/plain; charset=UTF-8
I can easily add the missing headers to the php generated text file.
But I don't want "Connection: Keep-Alive" or "Keep-Alive: timeout=15,
max=97" sent. That's my main problem at the moment. Any ideas on how
to not send those? Or how to "filter them out" using PHP?
Someone said I could use mod_rewrite to get an exact response which is
identical to the static normal text file from my php generated one.
But I don't know how to do that using mod_rewrite. Any ideas on that
approach?
Thanks for reading my post!
---------------------------------------------------------------------
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
Re: [users@httpd] Dynamic text-file created by PHP
Posted by Eric Covener <co...@gmail.com>.
On Jan 26, 2008 3:47 AM, Kent Larsson <ke...@gmail.com> wrote:
> > On 25.01.08 06:59, Kent Larsson wrote:
> > you can make the .txt a php script and force pargins by php parser by using
> > <Files> and SetHandler
>
> Thank you! But I still don't get it to work.
> <Files "txtfilefromphp.txt">
> SetType application/x-httpd-php
> </Files>
Tried SetHandler as suggested?
--
Eric Covener
covener@gmail.com
---------------------------------------------------------------------
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
Re: [users@httpd] Dynamic text-file created by PHP
Posted by Kent Larsson <ke...@gmail.com>.
> On 25.01.08 06:59, Kent Larsson wrote:
> > I want to create a dynamic textfile using PHP for each request of it. If the
> > users asks for http://server/textfile.txt I want a PHP-script to execute and
> > serve the textual data completely transparent to the user. This is a "single
> > case" so associating all txt-files with PHP is not what I would like to do.
> >
> > Which method would be the cleanest to use in this case? It's not a complex
> > rewrite.
>
> you can make the .txt a php script and force pargins by php parser by using
> <Files> and SetHandler
Thank you! But I still don't get it to work.
Some output: (cat shows the contents of a text file and $ is my command prompt)
$ cat txtfilefromphp.txt
<?php
echo 'This should be a text-file';
?>
$ cat .htaccess
<Files "txtfilefromphp.txt">
SetType application/x-httpd-php
</Files>
When I surf to it I still get:
<?php
echo 'This should be a text-file';
?>
Which means that it's interpreted as normal text file. I would like
the user to read the echo line and think (s)he is reading a normal
text file, not a dynamically generated one.
Step one is getting PHP to parse the script. After that I'll have to
imitate the http-header so that it exactly matches a normal text file.
But I'm still having problems with step one.
Has anyone got any suggestions?
---------------------------------------------------------------------
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
Re: [users@httpd] Dynamic text-file created by PHP
Posted by Matus UHLAR - fantomas <uh...@fantomas.sk>.
On 25.01.08 06:59, Kent Larsson wrote:
> I want to create a dynamic textfile using PHP for each request of it. If the
> users asks for http://server/textfile.txt I want a PHP-script to execute and
> serve the textual data completely transparent to the user. This is a "single
> case" so associating all txt-files with PHP is not what I would like to do.
>
> Which method would be the cleanest to use in this case? It's not a complex
> rewrite.
you can make the .txt a php script and force pargins by php parser by using
<Files> and SetHandler
--
Matus UHLAR - fantomas, uhlar@fantomas.sk ; http://www.fantomas.sk/
Warning: I wish NOT to receive e-mail advertising to this address.
Varovanie: na tuto adresu chcem NEDOSTAVAT akukolvek reklamnu postu.
The 3 biggets disasters: Hiroshima 45, Tschernobyl 86, Windows 95
---------------------------------------------------------------------
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