Change PHP version for specific domains in cPanel

Create a .htaccess in the root of the directory and append this line anywhere in the file.

AddHandler application/x-httpd-alt-php74___lsphp .php

Here 74 represents PHP version 7.4. If we want 8.1, it would be 81.