If you need to run a specific version of PHP for a plugin, script, or legacy application in a certain folder, you can assign a different PHP version to any directory within your hosting account using .htaccess.
This also applies to any additional domains you’ve added under the same control panel — each can be configured separately.
How to Set a Specific PHP Version per Directory:
-
Open File Manager from the control panel or connect to your account via FTP.
-
Navigate to the folder (or root directory of an add-on domain) where you want a different PHP version.
-
Create or edit the
.htaccessfile in that folder. -
Add the following code to the top of the file:
-
Save the file.
This will apply PHP 8.2 to all .php files in that directory and its subdirectories.
Supported PHP Versions:
Replace php82 in the code above with any of the following supported versions:
-
PHP 5.3 → php53
-
PHP 5.4 → php54
-
PHP 5.5 → php55
-
PHP 5.6 → php56
-
PHP 7.0 → php70
-
PHP 7.1 → php71
-
PHP 7.2 → php72
-
PHP 7.3 → php73
-
PHP 7.4 → php74
-
PHP 8.0 → php80
-
PHP 8.1 → php81
-
PHP 8.2 → php82
-
PHP 8.3 → php83
-
PHP 8.4 → php84
Make sure the version you choose is available in your hosting plan.
Important Notes:
-
Do not remove the
#+PHPVersionand#-PHPVersionlines — they are required. -
This method works for:
-
Your main domain
-
Subdirectories like
/api,/oldsite, etc. -
Additional domains hosted under the same control panel
-
-
Avoid setting conflicting
AddHandlerrules in parent.htaccessfiles.
Common Use Cases:
-
Running older PHP applications that aren't compatible with newer versions.
-
Creating a test environment with a different PHP version.
-
Isolating apps that require specific PHP settings.
