php.htaccessvirtualhostzend-server-ce

htaccess causing index.php to download


I am working on a site that depends on the following htaccess file to create something of a virtual directory structure by redirecting to an index.php whenever the specified url doesn't exist on the system.

AddHandler php5-script .php
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?p=$1 [L,QSA]

That seems to work fine on the client's existing server. It invisibly redirects things like domain.com/checkout to domain.com/index.php?p=checkout

My problem is that on my local development environment, this causes any non-existing url like that domain.com/checkout, or even the root domain.com to DOWNLOAD the index.php

If I try to load a specific file that exists in the website such as domain.com/index.php then it parses and displays in the browser properly.

In case it matters, my development environment is configured with a Virtual Host on Zend Server Community Edition.


Solution

  • I suppose you've already configured PHP in your development server for all files with the *.php extension. That means that doing it again in your .htaccess files is not only unnecessary but it can possibly cancel your server's configuration (as it's actually doing). Thus you need to get rid of this line:

    AddHandler php5-script .php
    

    The question is why it's there in the first place. I'd expect any PHP-enabled hosting service to be configured by default :-?