How To Change Different PHP Version By .htaccess

Hi Friends, In this article I will explain how can we change version of PHP by htaccess. Sometime some application need php version 5 instead of 4 and on server php4 version used by default but If php5 already installed on server then we can use php5 version by putting one line in .htaccess file.

If you want to use php5 version for a particular application and on server php4 and php5 both are available and php4 is by default , So to use php5 for that application follow these rules :
For e.g. our site application is in http://example.com/php5/ right now it is using php4 but you want to use php5 for this then,

1.  Make one .htaccess file in http://example.com/php5/ if not exists.

2.  Now put one line given below in .htaccess file.

AddHandler application/x-httpd-php5 .php .php5 .php4 .php3
Or
AddHandler x-httpd-php5 .php

You can try both one by one in case if any one is not working.

Now check your application site, It will use php5 version. Only this application will use php5 because we put htaccess which have php5 rule in this folder.

Subscribe to PHP Freelancer

Enter your email address: