Cookie Consent by Privacy Policies website

How to change the PHP version for subfolders or subdomains in Hostinger

In this article, we will see Setting a specific PHP version for additional websites, subfolders, or subdomains
⚙️⚙️⚙️

If you want to update the PHP version applicable to all of your hosting account, you can do it directly in hPanel simply by going to HostingManage, search for PHP Configuration on the sidebar and click on it:

How to change the PHP version for subfolders or subdomains in Hostinger
Changing PHP Version From Hosting Management Dashboard

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:

Steps to change the PHP version for subfolders or subdomains

Step 1 – Open your .htaccess file

Go to HostingManage, search for File Manager (beta) on the sidebar and click on it:

How to change the PHP version for subfolders or subdomains in Hostinger
File manager

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:

How to change the PHP version for subfolders or subdomains in Hostinger
.htaccess files in directory

For a specific folder, simply 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!

How to change the PHP version for subfolders or subdomains in Hostinger
Create .haccess file

Step 2 – Edit .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-lsphp71
</FilesMatch>

The second line will define the PHP version for the folder. All you need to do is change application/x-lsphp71 code for the version that you would like to use. Check this table for the possible values:

PHP versionCode
5.2application/x-lsphp52
5.3application/x-lsphp53
5.4application/x-lsphp54
5.5application/x-lsphp55
5.6application/x-lsphp56
7.0application/x-lsphp70
7.1application/x-lsphp71
7.2application/x-lsphp72
7.3*application/x-lsphp73
7.4application/x-lsphp74
8.0application/x-lsphp80
8.1application/x-lsphp81

*PHP versions prior to this one are currently considered outdated and are no longer supported.