AddType application/x-httpd-php .html stopped working

I have the following line in .htaccess

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

And it used to work for years to treat html pages as php, however recently I noticed it is not working anymore, except only in the homepage (example.com), and not even at the same page (example.com/index.html)

I tried now to add the following to /etc/apache2/mods-enabled/php5.6.conf and restarted apache, but still it didn't work. Also tried other suggestions here, but still no luck.

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

Any idea what could have happened? Or how to fix that?


Solution 1:

Find out your handler by creating a PHP file with following contents

<?php echo $_SERVER['REDIRECT_HANDLER']; ?>

When opened from browser, it will return the handler name for php. Then replace your current htaccess code with correct handler. For example, if your output is application/x-httpd-php5, then your htaccess will look like this:

<FilesMatch ".+\.html$">
SetHandler application/x-httpd-php5
</FilesMatch>

Reference: https://stackoverflow.com/a/49375772/2703813