{"id":290,"date":"2025-08-31T18:10:25","date_gmt":"2025-08-31T18:10:25","guid":{"rendered":"https:\/\/yesdomain.io\/kb\/?p=290"},"modified":"2025-08-31T18:10:28","modified_gmt":"2025-08-31T18:10:28","slug":"how-to-set-a-custom-php-version-per-directory","status":"publish","type":"post","link":"https:\/\/yesdomain.io\/kb\/how-to-set-a-custom-php-version-per-directory\/","title":{"rendered":"How to Set a Custom PHP Version per Directory in YesDomain Hosting"},"content":{"rendered":"\n<p>Running the right PHP version is very important for both <strong>performance<\/strong> and <strong>application compatibility<\/strong>. Some scripts or CMS platforms may only support older PHP versions, while others require the latest stable version.<\/p>\n\n\n\n<p>With <strong>YesDomain Hosting<\/strong>, you can configure <strong>different PHP versions for each domain, subdomain, or even a specific folder<\/strong> within your account. For example:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Your main website can run on PHP 8.1 for speed and security.<\/li>\n\n\n\n<li>A legacy web app inside a subfolder can still use PHP 7.4.<\/li>\n<\/ul>\n\n\n\n<p>Although the YesDomain control panel provides a <strong>global PHP selector<\/strong>, you can set a <strong>custom PHP version per directory<\/strong> by adding a few rules inside the <code>.htaccess<\/code> file.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">Why Set Custom PHP Versions?<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Compatibility<\/strong>: Run older apps that don\u2019t support the latest PHP.<\/li>\n\n\n\n<li><strong>Testing<\/strong>: Safely test your website on a new PHP version without affecting the entire account.<\/li>\n\n\n\n<li><strong>Flexibility<\/strong>: Assign different PHP versions for different addon domains or projects.<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">Steps to Configure a Custom PHP Version in a Directory<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">Step 1: Access File Manager<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Log in to your <strong>YesDomain Control Panel<\/strong>.<\/li>\n\n\n\n<li>Open the <strong>File Manager<\/strong>.<\/li>\n\n\n\n<li>Navigate to the folder or domain directory where you want to set a custom PHP version.<\/li>\n<\/ol>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">Step 2: Create or Edit <code>.htaccess<\/code><\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Look for an existing <code>.htaccess<\/code> file in that directory.<\/li>\n\n\n\n<li>If it does not exist, create a new file named <code>.htaccess<\/code>.<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">Step 3: Add PHP Version Handler<\/h3>\n\n\n\n<h4 class=\"wp-block-heading\">Example: Set PHP 5.6 for a Specific Folder<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code># YesDomain Custom PHP Version 5.6\n&lt;FilesMatch \"\\.(php4|php5|php3|php2|php|phtml)$\"&gt;\nSetHandler application\/x-lsphp56\n&lt;\/FilesMatch&gt;\n# Custom PHP Version Code Ends\n<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Example: Set PHP 7.0 for a Specific Folder<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code># YesDomain Custom PHP Version 7.0\n&lt;FilesMatch \"\\.(php4|php5|php3|php2|php|phtml)$\"&gt;\nSetHandler application\/x-lsphp70\n&lt;\/FilesMatch&gt;\n# Custom PHP Version Code Ends\n<\/code><\/pre>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p>\u26a0\ufe0f <strong>Note:<\/strong> Replace <code>lsphp56<\/code> or <code>lsphp70<\/code> with the version handler you want (e.g., <code>lsphp74<\/code>, <code>lsphp80<\/code>, <code>lsphp81<\/code>).<\/p>\n<\/blockquote>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">Step 4: Save and Test<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Save changes to the <code>.htaccess<\/code> file.<\/li>\n\n\n\n<li>Open the website or subdirectory in a browser.<\/li>\n\n\n\n<li>To verify, create a <code>phpinfo.php<\/code> file inside that directory with this code:<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;?php phpinfo(); ?&gt;\n<\/code><\/pre>\n\n\n\n<ol start=\"4\" class=\"wp-block-list\">\n<li>Open <code>yourdomain.com\/phpinfo.php<\/code> and check the PHP version running.<\/li>\n<\/ol>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">Troubleshooting<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>500 Internal Server Error<\/strong> \u2192 This usually happens if you entered an incorrect PHP handler. Double-check the handler name.<\/li>\n\n\n\n<li><strong>Changes not applying<\/strong> \u2192 Ensure the <code>.htaccess<\/code> file is inside the correct folder.<\/li>\n\n\n\n<li><strong>Conflicts<\/strong> \u2192 If you already have custom <code>.htaccess<\/code> rules, place the PHP handler code at the top.<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">FAQs<\/h2>\n\n\n\n<p><strong>Q1. Can I set PHP 8.2 only for a subdomain?<\/strong><br>Yes. Just edit the <code>.htaccess<\/code> file inside the subdomain\u2019s <code>public_html<\/code> folder.<\/p>\n\n\n\n<p><strong>Q2. Will this affect my main domain?<\/strong><br>No. These rules only apply to the specific folder where the <code>.htaccess<\/code> file is placed.<\/p>\n\n\n\n<p><strong>Q3. What if my script stops working after changing PHP?<\/strong><br>Switch back to the previous version by editing <code>.htaccess<\/code> again, or update your script to support newer PHP versions.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">Related Articles<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>How to Change PHP Version Globally in YesDomain Hosting<\/li>\n\n\n\n<li>How to Edit the .htaccess File in YesDomain Hosting<\/li>\n\n\n\n<li>How to Enable PHP Extensions in YesDomain Control Panel<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">Next Steps<\/h2>\n\n\n\n<p>Now you know how to run <strong>multiple PHP versions on a single YesDomain account<\/strong>. This gives you maximum flexibility for managing different apps and websites.<\/p>\n\n\n\n<p>Need more help? Contact the <strong>YesDomain Support Team<\/strong> anytime.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Running the right PHP version is very important for both performance and application compatibility. Some scripts or CMS platforms may only support older PHP versions, while others require the latest stable version. With YesDomain Hosting, you can configure different PHP versions for each domain, subdomain, or even a specific folder within your account. For example: &#8230; <a title=\"How to Set a Custom PHP Version per Directory in YesDomain Hosting\" class=\"read-more\" href=\"https:\/\/yesdomain.io\/kb\/how-to-set-a-custom-php-version-per-directory\/\" aria-label=\"Read more about How to Set a Custom PHP Version per Directory in YesDomain Hosting\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[48],"tags":[],"class_list":["post-290","post","type-post","status-publish","format-standard","hentry","category-technical-how-to-guides"],"_links":{"self":[{"href":"https:\/\/yesdomain.io\/kb\/wp-json\/wp\/v2\/posts\/290","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/yesdomain.io\/kb\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/yesdomain.io\/kb\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/yesdomain.io\/kb\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/yesdomain.io\/kb\/wp-json\/wp\/v2\/comments?post=290"}],"version-history":[{"count":1,"href":"https:\/\/yesdomain.io\/kb\/wp-json\/wp\/v2\/posts\/290\/revisions"}],"predecessor-version":[{"id":291,"href":"https:\/\/yesdomain.io\/kb\/wp-json\/wp\/v2\/posts\/290\/revisions\/291"}],"wp:attachment":[{"href":"https:\/\/yesdomain.io\/kb\/wp-json\/wp\/v2\/media?parent=290"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/yesdomain.io\/kb\/wp-json\/wp\/v2\/categories?post=290"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/yesdomain.io\/kb\/wp-json\/wp\/v2\/tags?post=290"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}