Why? Because the ancient, original file was .html and has been spidered by Google, etc.
I have an .html file that contains some php code. For my older version of PHP/Apache, I had some .htaccess lines that took care of this. Since upgrading to the latest, this no longer works. I’ve tried a half-dozen suggestions (AddType, AddHandler, RewriteRule) for how to do this in the hopes that it will work with PHP 7.4 and Apache/2.4.46, but nothing seems to work. What works on the above configuration? All permutations cause clicking on a link to the .html file for it to be downloaded by the browser – and it’s just the raw file (you can see the php code within it).
btw: phpInfo says Server API: "FPM/FastCGI"
Works on PHP 5.6 (but not on PHP 7.3/7.4)
AddHandler php5-script .php .html .htm
Works on PHP 7.3 (but not on PHP 7.4)
AddHandler application/x-httpd-php .html
Fails on PHP 7.4 (each tested individually, just one line in the .htaccess file)
AddHandler application/x-httpd-php .html
AddType application/x-httpd-php .html
AddHandler php-script .php .html .htm
AddHandler fcgid-script .php .htm .html
AddHandler php7-script .php .html .htm
AddHandler php7.4-script .php .html .htm
AddHandler php70-cgi .php .html
AddHandler php74-cgi .php .html
AddType x-mapp-php4 .html .htm
AddHandler FPM/FastCGI .php .html
<FilesMatch ".+.html?$">
SetHandler application/x-httpd-php
</FilesMatch>
I’m testing by directly modifying the .htaccess file on the server and clicking on the link to the .html page within a browser, no refreshes or restarts of anything.
btw: this combination of PHP and Apache is one of the options provided by AWS Elastic Beanstalk, which is where this is running
Thanks!
Peter
2
Answers
Try this, it should work for PHP 7.4
Try this:
That is not just
-php
but-lsphp