Skip to main content
All CollectionsPHPPHP Versions
How to change the PHP version for subfolders or subdomains
How to change the PHP version for subfolders or subdomains

Setting a specific PHP version for a specific websites, subfolders or subdomains

Updated over a week ago

If you want to update the PHP version applicable to your hosting plan as a whole, you can do it directly in hPanel.

In case you'd like to change the PHP version for only one of your domains, subdomains, or a subfolder inside any of these, you can do so by adding a line of code on the .htaccess file:

Step 1 - Open the .htaccess file

Go to Websites → Dashboard, search for File Manager on the sidebar and click on it:

Then, access the folder to which you would like to apply a different PHP version. If you want to edit a domain, access its public_html folder. For a subdomain, the corresponding folder will be inside the domain's public_html folder:

For a specific folder, go to the desired folder's path. Once in the correct location, open the .htaccess file by double-clicking on it.

If the file doesn't exist, you can create it directly in the File Manager. Make sure to include a dot (.) at the beginning of the filename!

Step 2 - Edit the .htaccess file

Add the following code to your .htaccess file (at the very beginning of it):

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

Replacing the application/x-lsphp74 portion of the code with the version that you would like to use. Check this table for the possible values:

PHP version

Code

7.3

application/x-lsphp73

7.4

application/x-lsphp74

8.0

application/x-lsphp80

8.1

application/x-lsphp81

8.2

application/x-lsphp82

8.3

application/x-lsphp83

It is recommended to use only PHP version 7.3 or higher. Lower versions are deprecated and can generate security risks and performance issues on your website.

NOTES

  • To check if the change was applied correctly, you can create a phpinfo.php file.

  • Using this method to change the PHP versions will not include PHP extensions and options.

  • Using the php -v command on SSH will show the PHP version of the hosting plan, not the domain or subdomain.

Did this answer your question?