.htaccess is the default Apache’s directory-level configuration file. It provides the ability to customize configuration directives. In this tutorial, I’ll show how to simply upgrade or switch your PHP version with .htaccess.
First, create a new file named: .htaccess or if you had it, open it and add the following line on the top of the file. Note that it’s always in the root of your website directory.
Upgrade/switch to PHP 5
AddHandler application/x-httpd-php5 .php .php5 .php4 .php3
— Or you can try —
Upgrade/switch to PHP 5.1
AddHandler application/x-httpd-php51 .php .php5 .php4 .php3
Upgrade/switch to PHP 5.2
AddHandler application/x-httpd-php52 .php .php5 .php4 .php3
Upgrade/switch to PHP 5.3
AddHandler application/x-httpd-php53 .php .php5 .php4 .php3
— Or —
Downgrade/switch to PHP 4
AddHandler application/x-httpd-php4 .php .php4 .php3