How to Set the PHP Version per Folder?


Do you have a single domain, or do you want to use a different PHP version for each folder? Do you have software installed in a folder (e.g., /blog) that requires PHP 5.x, but you want to use PHP 7.x instead? If so, you can achieve this using cPanel and the .htaccess file.

  1. Log into your cPanel account.
  2. In the "Software" section, click on the "MultiPHP Manager" icon.
    MultiPHP Manager Icon
  3. If you are new to this, the first step is to get the code generated by cPanel.
  4. Scroll down to the end of the page, select your domain from the left side, and you will see the "PHP Version" option with a drop-down list on the right. Select the appropriate PHP version from the drop-down menu and click the "Apply" button.
    Select PHP Version
  5. Open the /public_html/.htaccess file in the cPanel File Manager or your FTP client. You will find the code generated by cPanel there.
    Generated .htaccess Code
  6. To set PHP 7 for a specific folder (e.g., /forum), create a .htaccess file in that folder and paste the code generated in the previous step.
  7. Congratulations! Your /forum folder now uses PHP 7. If you want to set any other folder to use the same PHP version, simply copy the code from the .htaccess file and paste it into the desired folder's .htaccess file.

Note: To reset your PHP version for your main domain, repeat steps 5 and 6. Generate the code, copy it from /public_html/.htaccess, and paste it into any folder where you want to set your selected PHP version.


Was this answer helpful?

One email a month. Endless business benefits.

Don't miss out on WMTWWFY — the newsletter that keeps your website fast, safe, and visible.

« Back
Spinner
aluminium-anthropoid Security Check