1

The usual way of parsing .html files as PHP is to add either the first (PHP as an Apache module) or both (PHP as CGI) of the following lines to an .htaccess file:

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

Sometimes that needs to be x-http-php5, depending on the host:

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

However, I am now on a new host and no permeation of those lines work. In all cases the raw file is being sent to the browser, and wget shows that x-httpd-php is being presented as the Content-Type!

HTTP request sent, awaiting response... 
  HTTP/1.1 200 OK
  Date: Tue, 07 Aug 2012 14:16:40 GMT
  Server: Apache
  Last-Modified: Tue, 07 Aug 2012 07:46:44 GMT
  ETag: "862239-14-4c6a83216c100"
  Accept-Ranges: bytes
  Content-Length: 20
  X-Powered-By: PleskLin
  Keep-Alive: timeout=15, max=100
  Connection: Keep-Alive
  Content-Type: application/x-httpd-php
Length: 20 [application/x-httpd-php]
Remote file exists.

Note that Length: 20 is exactly the length of <?php phpinfo(); ?>, and that is what it is serving. I have confirmed that PHP is running as a module with the terrific tip in this SO answer. I have spoken with the maintainer of the server (an associate, so even if I switch hosts I would still like to help him resolve the issue) and he does not know what the issue or correct configuration is. The server is running Plesk on a Debian-based distro, if that matters at all.

2
  • I think this would be more appropriate in ServerFault, but I'm pretty sure it would be a duplicate there.
    – Lie Ryan
    Aug 7, 2012 at 15:33
  • I think that you're right, this would be better off on ServerFault. I don't have move permissions, though. A quick look around there only finds people asking how to configure their .htaccess files to parse .html files as PHP, but no questions as to how to configure the server to support it. So, this is not a dupe. (I wish that it were!)
    – dotancohen
    Aug 7, 2012 at 15:42

1 Answer 1

0

This was in fact an Apache configuration issue, this page had the solution: http://kb.parallels.com/en/124

Reproduced here for posterity:

.htaccess files can be enabled by placing the following in the "/etc/httpd/conf.d/zz010_psa_httpd.conf" file:

AccessFileName .htaccess

<Directory "/var/www/vhosts">
Options +All
AllowOverride All
Order allow,deny
Allow from all
</Directory>

Then restart Apache:

#service httpd stop
#service httpd start

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .