Content Negotiation in Apache 2
Date: 07/10/05
(Apache) Keywords: php, html, apache
I've set up content negotiation according to http://httpd.apache.org/docs-2.0/content-negotiation.html (using Options MultiViews
in my Directory
sections), and it all sort of works. Kind of.
To test things, I've created a file in the root of my server called phpinfo.php
. In it, I'm calling PHP's phpinfo()
function. If I call the file with its extension, I get the expected results. However, if I call the file without its extension, I get a prompt to download a file of type appliation/x-httpd-php
named phpinfo
.
Here is the relevant section of /etc/apache2/sites-enabled/000-default
(which is a link to /etc/apache2/sites-available/default
):
DocumentRoot /var/www/
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
# This directive allows us to have apache2's default start page
# in /apache2-default/, but still have / go to the right place
RedirectMatch ^/$ /apache2-default/
I have the information for parsing PHP in /etc/apache2/apache2.conf
(actually, it was already there; I merely had to uncomment it):AddCharset shift_jis .sjis
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
AddType application/x-tar .tgz
The reasoning behind using MultiViews right now instead of type-maps is because I don't want to have to define type-maps for every single file/resource I'm going to provide. If a type-map doesn't exist for a resource, content negotiation will fall back to MultiViews.
Am I missing something? Obviously, I am. Why am I being prompted to download the file? Why isn't the file being parsed by the server, like I'm telling it to?
NOTE: I had content negotiation working with Apache 1.3. It was only when I upgraded to Apache 2 that it stopped working as expected.
cross-posted to cparker
Source: http://www.livejournal.com/community/apache/22070.html