How to Set Custom PHP Version per Directory (Advanced)

Our Support Team are NOT web-developers and can not assist with details mentioned within any Advanced articles. Any changes applied to your files and folders need to be submitted by you or your web-developer. Any information mentioned in these advanced articles are general in nature, as such, any changes made are the sole responsibility of the account holder.


The hosting accounts PHP Version can be set in multiple ways. This article will cover the use of the .htaccess file to assign for a specified directory.


Your cPanel hosting uses the PHP Selector tool to set the account PHP Version, which you can find instructions for here. If different Versions of PHP need to be used, due to running different plugins or apps for a parked or subdomain, this will allow you to do that.


Using the File Manager tool under Files, select the Settings option in the top right corner. Ensure that the Show Hidden Files is enabled. This step is required for the .htaccess file to be visible within your folders.

To set a custom PHP version for the required directory, either select the .htaccess file and click on Edit from the toolbar, or right-click on it and select the Edit option

Within the  .htaccess editor, аt the top of the file, insert the PHP handler for the version you would like to use. If there is a handler in the file already, it should be removed or replaced with your new handler. Below are examples of Handlers that can be used:

For PHP 5.6:

AddHandler application/x-httpd-php56 .php .php5 .phtml

For PHP 7.4:

AddHandler application/x-httpd-ea-php74 .php .php7 .phtml

For PHP 8.0:

AddHandler application/x-httpd-ea-php80 .php .php8 .phtml

For PHP 8.1:

AddHandler application/x-httpd-ea-php81 .php .php8 .phtml



Was this article helpful?
0 out of 0 found this helpful