0

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

but index.php returns with the info

wich setting needs to be adjusted?

thanks

2 Answers 2

1

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
</FilesMatch>

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

1
  • thanks, I was surprised it did not work because on my hosting-provider it's not a problem
    – Richard
    Jun 1, 2013 at 0:25
1

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 

You must log in to answer this question.

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