Web hosting
How to set custom PHP version per directory through cPanel
In order to set a different PHP version to a directory, you need to add the following lines to the .htaccess file that is located in the folder of this page.
<FilesMatch "\.(php4|php5|php3|php2|php|phtml)$"> SetHandler application/x-httpd-alt-phpxx___lsphp </FilesMatch>
Where xx you type the version that you want to set. For example, if you want to set 8.1 version, you need to type:
SetHandler application/x-httpd-alt-php81___lsphpp
With the above procedure, the default PHP version of your cPanel will be the version that has been set through :
cPanel > Software > Select PHP Version
which will be used by all the pages that have not included the above lines in their .htaccess file.In case you need to add more sites in your account in the future, you can use the above method to have custom PHP version for every site. If you also need to have different PHP version to a sub-folder of your site, you can accordingly add an .htaccess file to this sub-folder and add the sames lines there.
Note:CloudLinux OS does not officially custom PHP versions to a single cPanel account and therefore, we cannot guarantee the effectiveness of the above suggested method.





