How to force PHP 5.6 for files without extensions

twv

Verified User
Joined
Oct 31, 2003
Messages
177
This server runs PHP 7.2 and 5.6.
Code:
build options | grep php
PHP (default): 7.2 as mod_php
PHP (additional): 5.6 as php-fpm

One of the sites running PHP 5.6 has this in its .htaccess:
Code:
<FilesMatch "^[^.]+$"> 
  ForceType application/x-httpd-php 
</FilesMatch>
This is so that URLs like https://domain.tld/index are served by PHP. It has worked fine for many years.

Unfortunately, after a recent rebuild of PHP, these files are now served by PHP 7 and the site is getting errors like this:
Code:
[Thu Jun 13 09:44:25.728763 2019] [php7:error] [pid 17672] [client x.x.x.x:57610] PHP Fatal error:  Uncaught Error: Call to undefined function mysql_pconnect()
If I create a file "phpinfo.php", phpinfo() shows php 5.6, however if I put phpinfo() in a file called just phpinfo (no .php extension), it shows php 7.2.

How can I force files without an extension to be served by php 5.6?
 

smtalk

Administrator
Staff member
Joined
Aug 22, 2006
Messages
8,519
Location
LT, EU
application/x-httpd-php isn't a handler of PHP-FPM 5.6, that's why it defaults to the mod_php.
 
Top