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.

    UPDATE: Resolved; see note.

    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.

    NOTE: I've further edited my configuration, and I've noticed something very peculiar. Both my machine's IP address and cparker15.com point to the same place now. If I call phpinfo (without the extension) from cparker15.com, everything works as expected. However, if I swap cparker15.com for the IP address, I get a prompt to download the file. Any ideas?

    NOTE: Nevermind! I cleared Firefox's cache and tried again and all works now as expected. Thanks go to sub and TBF in #apache on EFnet for their help diagnosing my "problem".

    cross-posted to '[info]'cparker

    Source: http://community.livejournal.com/apache/22070.html

« Apache's connections || mod_rewrite to utf8 url »


antivirus | apache | asp | blogging | browser | bugtracking | cms | crm | css | database | ebay | ecommerce | google | hosting | html | java | jsp | linux | microsoft | mysql | offshore | offshoring | oscommerce | php | postgresql | programming | rss | security | seo | shopping | software | spam | spyware | sql | technology | templates | tracker | virus | web | xml | yahoo | home