Changing the PHP version for a directory
To change the PHP version for a specific directory, follow these steps:- Using your preferred text editor, create a file named .htaccess in the directory where you want to use a different PHP version.
-
Copy the following text:
-
Replace XX with the PHP version you want to use in the directory. You can use any PHP version that is listed in the cPanel PHP Selector. For example, to enable PHP 8.1, you would type
SetHandler application/x-httpd-alt-php81___lsphp. (Make sure you do not include the period in the version number. For example, for PHP version 7.4, type74.) - Paste the modified text into the .htaccess file.
-
Save the .htaccess file. The new PHP version takes effect immediately.
👍 Tip To verify the new configuration, create a PHP file that runs thephpinfo()function. Load the file in your web browser, and confirm the PHP version. For example: