Addhandler php html

  • Hello,

    Any idea how to make the "addhandler php html" so that php code to work within html files, by using .htaccess on an i-mscp web server?

    More info: i-mscp 1.1.12, on Ubuntu 14.04 LTS, PHP 5.5.9 and Apache 2.4.7


  • Unfortunately it is written in a language that I don't know. Hopefully Google Translate is going to be a good assistant. :)

  • I've got an ugly Error 500.

    The .htaccess I use contains,

    1. RewriteEngine On
    2. RewriteBase /
    3. RewriteCond %{HTTP_HOST} !^www\. [NC]
    4. RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
    5. RewriteRule ^(. *).Html $ $ 1.php
  • @TheCry :)

    @gOOvER You're right ;)

    Should be

    1. RewriteEngine OnRewriteBase /
    2. RewriteCond %{HTTP_HOST} !^www\. [NC]
    3. RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
    4. RewriteRule ^(.*).Html$ $1.php

    Note: I've just fixed the syntax. I've not tested those rewrite rules.


  • Thanks for the help but it does not solve the problem. The website of a customer has php code inside the normal html file and aparently it's not working.

  • Indeed, in that specific case, the rewrite rules above will not work because they are asking apache to translate any virtual <whatever>.html file to real file <whatever>.php.

    you'are using php5-fpm?

    If yes, you should try to add this in the .htaccess of your customer;

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

    Note: (You'll have maybe to change it vhost to allow those directive in its .htaccess file.

    and also edit its fpm pool conffile to allow execution of .html files.

    1. security.limit_extensions = .php .html

    Note: Not tested ;)


  • I had to modified the

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


    1. AddType application/x-httpd-php5 .html

    I'm using php-fpm indeed. I include the .html entry on security.limit_extensions and the effect is that the file is not executed, the browser starts to download the file.

    The fpm pool is located in /etc/php5/fpm/pool.d/ isn't it?