{"id":50449,"date":"2026-11-20T05:24:10","date_gmt":"2026-11-20T05:24:10","guid":{"rendered":"https:\/\/kickhost.com\/guides\/how-to-set-the-php-version-per-directory-in-cpanel\/"},"modified":"2026-11-28T09:42:38","modified_gmt":"2026-11-28T09:42:38","slug":"how-to-set-the-php-version-per-directory-in-cpanel","status":"publish","type":"kickhost_tutorial","link":"https:\/\/kickhost.com\/en-ke\/guides\/how-to-set-the-php-version-per-directory-in-cpanel\/","title":{"rendered":"How to Set the PHP Version per Directory in cPanel"},"content":{"rendered":"<p>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.<\/p>\n<p>Do you want to use different PHP versions per directory? You can do this using cPanel and the dot htaccess file.<\/p>\n<p><strong>1.<\/strong> Log in to your cPanel account.<\/p>\n<p><strong>2.<\/strong> In the <strong>Software<\/strong> section, click on <strong>MultiPHP Manager<\/strong>.<br \/><img decoding=\"async\" src=\"https:\/\/kickhost.com\/img\/cpanel-multiphp-icon.gif\" loading=\"lazy\" alt=\"\"><\/p>\n<p><strong>3. <\/strong>The first thing we need to do is to get the code generated by cPanel.<\/p>\n<p><strong>4.<\/strong> Scroll down to the bottom of the page. Select your domain from the left side of the screen. You can view the <strong>PHP Version<\/strong> from the drop-down menu on the right. Please, select the appropriate PHP version from it and click on <strong>Apply<\/strong>.<br \/><img decoding=\"async\" src=\"https:\/\/kickhost.com\/img\/cpanel-multiphp-select-domain-full.gif\" loading=\"lazy\" alt=\"\"><\/p>\n<p><strong>5. <\/strong>First, open the <code>\/public_html\/.htaccess<\/code> file in the cPanel File Manager, and you will find the code generated by cPanel. <br \/><img decoding=\"async\" src=\"https:\/\/kickhost.com\/img\/cpanel-multiphp-version-generated.gif\" loading=\"lazy\" alt=\"\"><\/p>\n<p><strong>6. <\/strong>After you copy the code, should you wish to set the PHP to version 8.1 in the directory <strong>forums<\/strong>, create a .htaccess file in the directory \/forums\/ and paste the code generated in the previous step.<\/p>\n<p><strong>7.<\/strong> 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. <\/p>\n<p>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.<\/p>\n<h2>Use the handler cPanel gives you<\/h2>\n<p>Copy the exact lines cPanel shows for the version you choose. Do not guess them.<\/p>\n<h2>Keep a backup<\/h2>\n<p>Back up .htaccess before editing. A wrong rule can cause a 500 error.<\/p>\n<h2>Frequently asked questions<\/h2>\n<p><strong>Can a subfolder use a different version?<\/strong> Yes. Place the rule in that folder.<\/p>\n<p><strong>Which version should I use?<\/strong> The newest version your application supports.<\/p>\n<h2>Related guides<\/h2>\n<ul>\n<li><a href=\"https:\/\/kickhost.com\/en-ke\/guides\/how-to-set-the-php-version-per-domain-in-cpanel\/\">Set PHP per domain<\/a><\/li>\n<li><a href=\"https:\/\/kickhost.com\/en-ke\/guides\/how-to-edit-dothtaccess-file-in-the-cpanel-file-manager\/\">Edit the .htaccess file<\/a><\/li>\n<\/ul>\n<p>Need cPanel hosting in Kenya? <a href=\"https:\/\/kickhost.com\/en-ke\/web-hosting\/\">See KickHost hosting plans<\/a> or <a href=\"https:\/\/kickhost.com\/en-ke\/contact\/\">contact our team<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Set a different PHP version per directory in cPanel using .htaccess. Steps for KickHost customers in Kenya.<\/p>\n","protected":false},"featured_media":0,"template":"","class_list":["post-50449","kickhost_tutorial","type-kickhost_tutorial","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/kickhost.com\/en-ke\/wp-json\/wp\/v2\/kickhost_tutorial\/50449","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/kickhost.com\/en-ke\/wp-json\/wp\/v2\/kickhost_tutorial"}],"about":[{"href":"https:\/\/kickhost.com\/en-ke\/wp-json\/wp\/v2\/types\/kickhost_tutorial"}],"version-history":[{"count":3,"href":"https:\/\/kickhost.com\/en-ke\/wp-json\/wp\/v2\/kickhost_tutorial\/50449\/revisions"}],"predecessor-version":[{"id":53450,"href":"https:\/\/kickhost.com\/en-ke\/wp-json\/wp\/v2\/kickhost_tutorial\/50449\/revisions\/53450"}],"wp:attachment":[{"href":"https:\/\/kickhost.com\/en-ke\/wp-json\/wp\/v2\/media?parent=50449"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}