Hello everybody!

I am new to this list. I hope it's the right place to ask my question.

I am using PHP 4.0.6 (mod_php) / Apache 1.3.20 / Mandrake 8.1. I also
use content-negotiation on the same server. Therefore I have the
following directives in Apache's config:

    LoadModule php4_module extramodules/libphp4.so
    AddModule mod_php4.c
    AddType application/x-httpd-php .php
    Options +MultiViews

When I browse the site whith Mozilla, everything works fine. A request
for a non existent /some/file will return either /some/file.html or
/some/file.php, whichever exists. In either case Apache will give the
right (text/html) Content-Type to the browser. So far so good, that was
what I wanted.

However, when I try to spider the site with Plucker
<URL:http://www.plkr.org/>, I get this kind of errors:

    HTTP/1.1 406 Not Acceptable
    Alternates: {"file.php" 1 {type application/x-httpd-php} {length 5917}}
    Vary: negotiate

I traced the problem to the Accept header sent by the client. Mozilla
assumes it can handle any file type, and therefore sends an Accept
header that contains the "*/*" (i.e. any) type. Plucker knows it can
only handle certain file types, so it sends a more specific Accept
header containing text/html but nothing that would match
application/x-httpd-php. Apache thinks that /some/file.php has type
application/x-httpd-php and is therefore not suitable for a client
asking for text/html, which is wrong since a request for /some/file.php
would yield Content-Type: text/html. The problem here is that for
content-negotiation to work correctly, Apache needs to know the MIME
type the script will give without running it.

I read the mod_mime documentation and it seems to me that AddType and
AddHandler are meant to associate a Content-Type and a handler,
respectively, to a file, not the other way around. Using AddType to
ensure that the files are handled by mod_php (as in AddType
application/x-httpd-php .php) seems to be the wrong thing to do.
Something like

    AddType text/html .php      # assuming they all output HTML
    AddHandler php-script .php

looks more appropriate. However this seems to work (with an extra Action
directive) when PHP is installed as a GCI, not when it is installed as a
module.

Is there a way to tell Apache to pass the file through the PHP module
without changing its MIME type to anything other than text/html? Or any
other way to get mod_php work with content-negotiation?

Thanks,

Edgar.

-- 
PHP Install Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to