Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I moved a website from another server to mine and there is a PHP file with .ph extension. On other server it worked fine, but not on the new one. It just tries to download the file in question, instead of sending it through PHP parser.

Obviously it's about file handlers, so I need to add .ph extension to be handled as .php file. I thought this was trivial, but still couldn't do it :) It has somehow changed in Apache2 and I can't seem to figure it out.

I've tried to set the handler in mime.conf and in /etc/mime.types. Nothing so far.

Due to the app complexity, I wish I wouldn't have to change the extension of the file. Could someone point me to the right direction? This shouldn't be this hard :)

I'm running Apache 2.2.17 and PHP 5.3.5 on Ubuntu 11.04.

share|improve this question

try this after modifying mime configuration

service apache2 restart

or edit your httpd.conf

Updated & tested:

AddHandler type-map var
AddHandler php5-script .ph
AddType text/html .php
share|improve this answer
Nope. At least adding AddType text/html .ph makes it stop to try to download the file in question, but no; it still won't parse it. – budwiser Feb 15 '12 at 7:22
already added into my test server and restart apache. it parse .ph and content php echo "HELLO WORLD" into HELLO WORLD only. – apis17 Feb 15 '12 at 7:27
i'm not add any MIME type. can you remove mime type and try again? – apis17 Feb 15 '12 at 7:27
Got it. But thanks for your help. – budwiser Feb 15 '12 at 7:42
up vote 0 down vote accepted

The problem seemed to be that I had this definition in my /etc/apache2/mods-available/php5.conf file:

<FilesMatch "\.ph(p3?|tml)$">
    SetHandler application/x-httpd-php

The regexp pattern expected either p3 or tml ending to .ph - prefix.

The easiest fix was just to add:

<FilesMatch "\.ph$">
    SetHandler application/x-httpd-php

into the file. Works like a charm now.

share|improve this answer
How can I add PHP to deal with files that do not have any extension? Is there a "DefaultHandler" directive? In Apache 2.2.29, with PHP 5.5, the following does not work: DefaultType application/x-httpd-php. Thank you. – PKHunter Jul 26 '15 at 7:42

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.