Your country & currency

Make yourself at home. Choose your preferred shopping currency.

Your selected country opens its KickHost website. Your shopping currency is saved. Visit country website .

Guide

How to Set the PHP Version per Directory in cPanel

Set a different PHP version per directory in cPanel using .htaccess. Steps for KickHost customers in Kenya.

Share

Sometimes one folder, such as an older app, needs a different PHP version than the rest of your site. You can set it with a rule in .htaccess.

Do you want to use different PHP versions per directory? You can do this using cPanel and the dot htaccess file.

1. Log in to your cPanel account.

2. In the Software section, click on MultiPHP Manager.
Cpanel multiphp icon

3. The first thing we need to do is to get the code generated by cPanel.

4. Scroll down to the bottom of the page. Select your domain from the left side of the screen. You can view the PHP Version from the drop-down menu on the right. Please, select the appropriate PHP version from it and click on Apply.
Cpanel multiphp select domain full

5. First, open the /public_html/.htaccess file in the cPanel File Manager, and you will find the code generated by cPanel.
Cpanel multiphp version generated

6. After you copy the code, should you wish to set the PHP to version 8.1 in the directory forums, create a .htaccess file in the directory /forums/ and paste the code generated in the previous step.

7. Congratulations, now your directory forums is using PHP 8.1. Should you wish to set any other directory to use the same version of PHP as well, you would only need to copy the code from the .htaccess file and paste it into that directory.

Now, reset your PHP version from your primary domain. Should you wish to use a different PHP version on any directory, follow steps five and six, generate the code, copy that code from /public_html/.htaccess and paste it into the directory where you want to set the selected PHP version.

Use the handler cPanel gives you

Copy the exact lines cPanel shows for the version you choose. Do not guess them.

Keep a backup

Back up .htaccess before editing. A wrong rule can cause a 500 error.

Frequently asked questions

Can a subfolder use a different version? Yes. Place the rule in that folder.

Which version should I use? The newest version your application supports.

Related guides

Need cPanel hosting in Kenya? See KickHost hosting plans or contact our team.

Found this useful? Share it.

Need a hand with this?

Our team can help you choose the right domain, hosting or server and set it up properly.

Talk to our team See hosting plans