You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Marten Lehmann <le...@cnm.de> on 2008/01/28 16:21:16 UTC

[users@httpd] test.html.php shown as html not as php

Hello,

using apache 2.2.4 we have these lines in our httpd.conf (among others 
of course):

AddType application/x-httpd-php .php
AddHandler server-parsed .html

This works generally fine: .php files are executed by the php 
interpreter and .html files processed by the SSI processor of apache.

Today a user informed us, that naming a file e.g. test.html.php results 
in an unexpected behaviour:

# telnet test.com 80
Trying 1.2.3.4...
Connected to test.com (1.2.3.4).
Escape character is '^]'.
GET /testcases/test.html.php HTTP/1.0
Host: test.com

HTTP/1.1 200 OK
Date: Mon, 28 Jan 2008 15:07:32 GMT
Server: Apache/2.2.8 (Unix) mod_ssl/2.2.8 OpenSSL/0.9.7a
Accept-Ranges: bytes
Content-Length: 31
Connection: close
Content-Type: application/x-httpd-php

<?

print "Test";
sleep(20);

?>

On the one hand, apache is setting the content-type 
"application/x-httpd-php", but on the other hand, the script isn't 
passed to the php intepreter.

It also doesn't work the other way round (test.php.html):

# telnet test.com 80
Trying 1.2.3.4...
Connected to gotmilk.eu (1.2.3.4).
Escape character is '^]'.
GET /testcases/test.php.html HTTP/1.0
Host: test.com

HTTP/1.1 200 OK
Date: Mon, 28 Jan 2008 15:19:56 GMT
Server: Apache/2.2.8 (Unix) mod_ssl/2.2.8 OpenSSL/0.9.7a
Accept-Ranges: bytes
Content-Length: 32
Connection: close
Content-Type: text/html

<?

print "Test";
sleep(20);

?>

Any ideas?

Regards
Marten

---------------------------------------------------------------------
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] test.html.php shown as html not as php

Posted by AJ McKee <aj...@druid-dns.com>.
Marten,

Should be (Although not really a good thing)

AddType application/x-httpd-php .php .html

AJ



---------------------------------------------------------------------
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] test.html.php shown as html not as php

Posted by Joshua Slive <jo...@slive.ca>.
On Jan 28, 2008 10:21 AM, Marten Lehmann <le...@cnm.de> wrote:
> Hello,
>
> using apache 2.2.4 we have these lines in our httpd.conf (among others
> of course):
>
> AddType application/x-httpd-php .php
> AddHandler server-parsed .html
>
> This works generally fine: .php files are executed by the php
> interpreter and .html files processed by the SSI processor of apache.
>
> Today a user informed us, that naming a file e.g. test.html.php results
> in an unexpected behaviour:

There are two problems here:

1. Using AddType to activate the php HANDLER. You should be using
AddHandler for php as well. (Yes, this is incorrectly document in the
php manual and has been that way forever. The php people don't seem to
be too concerned about this issue which hits people who deal with
multiple-extensions.)

2. Understand that files can have multiple extensions and apache will
apply config directives for each extension.

Using AddHandler properly will fix the test.html.php case, since the
handler for the last extension (php) will take precedence over the
INCLUDES handler. The test.php.html will still not work. If you want
that to work, you need to RemoveHandler for the .html extension for
that file.

Joshua.

---------------------------------------------------------------------
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] %T time to serve log entry

Posted by Max Dittrich <ma...@t-online.de>.
Tony Rice (trice) schrieb:
> Is there another Log format available that shows more resolution than
> seconds for time to serve a request?  Perhaps in milliseconds?

Microseconds are given with %D from mod_log_config
     http://httpd.apache.org/docs/2.2/mod/mod_log_config.html#formats

.max

---------------------------------------------------------------------
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


[users@httpd] %T time to serve log entry

Posted by "Tony Rice (trice)" <tr...@cisco.com>.
Is there another Log format available that shows more resolution than
seconds for time to serve a request?  Perhaps in milliseconds?

---------------------------------------------------------------------
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] test.html.php shown as html not as php

Posted by Marten Lehmann <le...@cnm.de>.
Hello,

>> AddType application/x-httpd-php .php
> 
> That's wrong.  PHP is a handler, not a MIME type.  That ugly hack
> was required by Apache 1.0, but has been a nasty bogosity since
> Apache 1.1 in 1996.

ah, I see. I started using it with my Apache 1.3.x config where it 
worked fine and then kept it until my 2.2.4 apache config since it works 
fine (except for the .html.php thing). But with the upgrade to 2.2.8 I 
will change this as well. I wili use

AddHandler application/x-httpd-php .php
AddHandler application/x-httpd-php .php3
AddHandler application/x-httpd-php .php4
AddHandler application/x-httpd-php5 .php5

instead.

>> AddHandler server-parsed .html
> 
> And that's been wrong since Apache 2.0 in 2002, when SSI ceased to
> be a content generator and became a filter.  The legacy support for
> SSI handlers precludes using dynamic contents with SSI.

Ok, I changed it to

AddType text/html .shtml
AddOutputFilter INCLUDES .html
AddOutputFilter INCLUDES .shtml

Seems to work fine.

Thanks!

Kind regards
Marten

---------------------------------------------------------------------
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] test.html.php shown as html not as php

Posted by Nick Kew <ni...@webthing.com>.
On Mon, 28 Jan 2008 16:21:16 +0100
Marten Lehmann <le...@cnm.de> wrote:

> Hello,
> 
> using apache 2.2.4 we have these lines in our httpd.conf (among
> others of course):
> 
> AddType application/x-httpd-php .php

That's wrong.  PHP is a handler, not a MIME type.  That ugly hack
was required by Apache 1.0, but has been a nasty bogosity since
Apache 1.1 in 1996.

> AddHandler server-parsed .html

And that's been wrong since Apache 2.0 in 2002, when SSI ceased to
be a content generator and became a filter.  The legacy support for
SSI handlers precludes using dynamic contents with SSI.

> HTTP/1.1 200 OK
> Date: Mon, 28 Jan 2008 15:07:32 GMT
> Server: Apache/2.2.8 (Unix) mod_ssl/2.2.8 OpenSSL/0.9.7a
> Accept-Ranges: bytes
> Content-Length: 31
> Connection: close
> Content-Type: application/x-httpd-php

That's exactly what you told it:
- the handler is "server-parsed", so php rightly doesn't touch it.
- the content-type is what you set.

-- 
Nick Kew

Application Development with Apache - the Apache Modules Book
http://www.apachetutor.org/

---------------------------------------------------------------------
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