Super User is a question and answer site for computer enthusiasts and power users. 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

For example, echo phpinfo() returns nothing in my .html file

but index.php returns with the info

wich setting needs to be adjusted?


share|improve this question
up vote 1 down vote accepted

You need to configure Apache to look for PHP in html files.

You can use either AddType, or FilesMatch, e.g.:

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

Note this could impact performance, as each HTML file will now be checked for PHP code.

FilesMatch is better then AddType as it'll protect you from some exploits. Details about this can be seen in step 6 of the php install manual

share|improve this answer
thanks, I was surprised it did not work because on my hosting-provider it's not a problem – Richard Jun 1 '13 at 0:25

you can not execute php code in an HTML file, the file needs to be a PHP file with an extension of .php or .php5

In order to execute PHP code inside HTML you will need to add a handler

Enter this in the .htaccess file in the root of your Apache web server

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

If you're running PHP as CGI:

AddHandler application/x-httpd-php .html .htm 
share|improve this answer

You must log in to answer this question.

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