How to set different versions of PHP for site directory

Typically, the php version is set for the site directory and is completely changed for the entire directory. However, sometimes unpredictable moments appear, when it is necessary to set an excellent version from the main one for a specific folder. The cpanel control panel even has an addition to the MultiPhp Manager, but not all hostings have the opportunity to put it or the technical support may not go to meet you in its installation. In this case, you can fix the situation using the file htacess.

In the directory we need, we create a .htaccess file with the following contents

<FilesMatch "\.(php4|php5|php3|php2|php|phtml)$">
SetHandler application/x-httpd-alt-php70___lsphp
</FilesMatch>

where the line

SetHandler application/x-httpd-alt-php70___lsphp

will say to the server which version of the PHP must be used when processing files in this folder.

Thus, you can substitute these lines to the version we need

application/x-httpd-alt-php44___lsphp
application/x-httpd-alt-php51___lsphp
application/x-httpd-alt-php52___lsphp
application/x-httpd-alt-php53___lsphp
application/x-httpd-alt-php54___lsphp
application/x-httpd-alt-php55___lsphp
application/x-httpd-alt-php56___lsphp
application/x-httpd-alt-php70___lsphp
application/x-httpd-alt-php71___lsphp
application/x-httpd-alt-php72___lsphp
application/x-httpd-alt-php73___lsphp
application/x-httpd-alt-php74___lsphp

This method was found on the website www.proisp.eu, for which many thanks to them.

Plain text

  • No HTML tags allowed.
  • Lines and paragraphs break automatically.
  • Web page addresses and email addresses turn into links automatically.
The comment language code.