Loading...

Knowledge Base

How to Use Different PHP Versions for Subfolders in cPanel

When different parts of your website require different PHP versions. This article explains how to assign PHP versions to subfolders in cPanel.

 

To use different PHP versions for your sub-folders, sub-domains and Add-on domains, you need to appropriate code lines to the .htaccess file present in the document root folder. 

Here is the code you can use to set a specific Version for a sub-folder 

 

Code to set PHP Version 7.3

# Use PHP7.3 as default
<IfModule mime_module>
  AddHandler application/x-httpd-ea-php73 .php .php7 .phtml
</IfModule>


Code to set PHP Version 7.4

# Use PHP7.4 as default
<IfModule mime_module>
  AddHandler application/x-httpd-ea-php74 .php .php7 .phtml


Thus you can set PHP 7.4 in the file /home/user/public_html/.htaccess and at the same time you can use PHP 7.3 via the file /home/user/public_html/subfolder/.htaccess.