Welcome to WebmasterWorld Guest from

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

Unable To Parse For PHP In HTML Pages

application/x-httpd-php .php .html



8:12 pm on Jan 18, 2013 (gmt 0)

WebmasterWorld Senior Member 5+ Year Member

I'm hoping someone here can point me in the right direction. I've literally been searching for a solution for more than 8 hours now and keep ending up in dead-ends. I'm just about ready to pull the last hair out of my coconut. I really need to get this resolved by day end so hoping someone here might have experienced this problem. I've been reading through so many forums and cannot find a solution.

I have previously created websites with PHP scripting embedded into pages with .html file extensions. To handle it I've always been able to simply add [ AddType application/x-httpd-php .php .html ] to my Apache httpd.conf file to handle it.

I've tried it in apache2.conf, httpd.conf, vhosts.conf -- not working. The environment is Ubuntu 12.04, Apache 2.2, Plesk 11.x?

I have outgrown my present server and upgraded. I'm in the process of applying the final server-wide configurations before migrating sites to my new server. I just found out that this is not going to work in the current environment. When I add that line and navigate to a page instead of the browser simply displaying it, it prompts me to download it with a message of -- [ You have chosen to open: which is a: application/x-httpd-php] -- it prompts me to choose a program to open it or save it.

I think I have narrowed it down a bit to being related to a combination of suPHP/PHP5/Server API CGI/FastCGI settings but cannot find a solution. Please, I hope someone has an answer, I'm going to go crazy if I cannot figure this out (we wouldn't want that would we!).

I really just want it to be as easy as it used to be. I don't want to have to rename site files to .php and also [ AddHandler application/x-httpd-php5 .php ] has not helped :(

I have to get away for a break to regroup but I will be checking back within a few hours in case someone recognizes this. Thanks folks.


8:44 pm on Jan 18, 2013 (gmt 0)

WebmasterWorld Senior Member 5+ Year Member

Oh I should have added that all scripts work as long the filename ends in .php. My earlier developed websites, I used .php extensions, but at some point I just decided to give security a helping hand by camouflaging the use of scripts on the server by building them into .html pages.

But, as soon as I add .html to the end of [ AddType application/x-httpd-php .php .html ] I run into the problem. Remove it and all scripts run except those in html page extensions.


12:02 am on Jan 19, 2013 (gmt 0)

WebmasterWorld Senior Member lucy24 is a WebmasterWorld Top Contributor of All Time Top Contributors Of The Month

Tangential solution: If you've got time constraints and you haven't arrived at a solution before you absolutely have to go live, there's always mod_rewrite.

:: idly wondering why we haven't yet got the sales pitch for Going Extensionless although it's been over 15 hours... ::

Did you try AddType too?

:: further Forums search leading to definitive answer [webmasterworld.com] (not from me, because I don't touch this stuff with a barge pole) ::

The AddType / AddHandler stuff is beyond confusing and I usually end up trying several combinations before I find the one that works OK.


1:08 am on Jan 19, 2013 (gmt 0)

WebmasterWorld Senior Member 5+ Year Member

Thanks Lucy for the pointer. I see the quote above was by g1smd so that implies it must be tough if he struggles with it.

It's not time critical yet. I have until Monday before I'll have to renew my old plan, unless they give me a grace period. If worst gets even worst I can always extend the plan for only a month until I get this resolved.

Resorting to mod_rewrite will be the last on my list. Before I do that I would prefer to just run my php as an Apache module -- shut down the fastCGI that is probably the root cause as it's set up right now.

I guess I'll plug away at it and if I get it running I'll post-back what worked. I say that because I think someone out there that had the same problem had posted it in another forum then came back and said he got it working -- but didn't write up the solution :(

It has been one challenge after another for the last 3 days, non-stop. I keep knocking them off but this one is getting the best of me. Some command line input for Plesk has changed too since I used version 9 compared to 11 that the ones I have in my head have to be relearned :(


3:29 am on Jan 19, 2013 (gmt 0)

WebmasterWorld Senior Member 5+ Year Member


AddHandler php-script .html -- It Works added to vhost.conf down the stream! That's the short answer.

I'll post a followup summary as soon as possible in the next couple days when I get a chance to catch my breath. There are many environmental variables in play here so it may not work for everyone. But I think this is new to recent versions of the combination of Ubuntu 12.04/Apache 2.2/PHP5/Plesk 11. I suspect there will be a flood of people looking for a solution like this as they upgrade like I'm doing. I also want to test it more as well as check logs to make sure it's not generating errors elsewhere but I'm too tired right now.

Gotta run, a sink full of dishes to wash in the kitchen -- mindless stress relief :)


5:13 am on Jan 19, 2013 (gmt 0)

WebmasterWorld Administrator 5+ Year Member Top Contributors Of The Month

I see that you've found a solution, if it gives you trouble, you can try altering your normal AddHandler line:

On some hosts I've had to alter the usual line to read:
AddHandler application/x-httpd-php5 .html .htm

(But in those cases php is not running as FastCGI)


5:42 pm on Jan 28, 2013 (gmt 0)

WebmasterWorld Senior Member 5+ Year Member

I was hoping to writeup a more in depth summary of my observations surrounding this issue but I'm still assessing it all. I've realized it's going to take a deeper plunge in understanding Plesk's method of "VPS in optimized mode" something I haven't done yet. So I'm going to leave this thread with this:

    It is directly related to fastCGI

    There are additional conflicts related to fastCGI and PHP as an Apache module vs as CGI vs as fastCGI in my environment of Ubuntu/Apache/Plesk 11.x but I cannot yet fully understand what is going on. It seems it's also all somehow related to VPS in optimized mode. In the end my control panel is not allowing me to use fastCGI, only CGI. But, when I run TOP via SSH it appears PHP is running as an Apache module.

    If the old proper syntax is used at the level of apache2.conf or httpd.conf it will cause all pages of all virtual hosts to open a dialog box prompting the visitor to select a program to open the file or download it, even pages with .php extensions

Historically the syntax for parsing .html docs for PHP was:

AddType application/x-httpd-php .php .html <--- but using this now will produce the dilemma mentioned above

Rather this is how to handle it now in apache2.conf or httpd.conf

AddType application/x-httpd-php .php
AddHandler php-script .html

Whereas further downstream in vhosts.conf or .htaccess the first line is not needed because it's included upstream so just add:

AddHandler php-script .html

All the above is related to fastCGI which is now the default method of handling PHP in Plesk 11.x+

AddHandler application/x-httpd-php5 .html .htm

That was one of many tried that didn't work.

Featured Threads

Hot Threads This Week

Hot Threads This Month