How can I change the PHP version to 5.2 on a server using either an .htaccess of php.ini file?
Asked
Active
Viewed 4.7k times
14
-
1According to [this answer](http://stackoverflow.com/questions/3127667/is-there-a-way-to-set-a-different-php-module-per-virtual-host) you can use different versions on different vhosts – Markus Hedlund Aug 24 '12 at 08:26
3 Answers
9
Adding
AddHandler application/x-httpd-php52 .php .php5 .php4 .php3
to your .htaccess might work.

Wayne Whitty
- 19,513
- 7
- 44
- 66
-
8I added this in my htaccess but when go to my homepage, it just downloaded my index.php file :/ what's the reason behind it? – Loreto Gabawa Jr. Jun 03 '14 at 19:09
-
3why this answer was chosen? it does not work. it just downloads my index.php file. – lyhong Sep 12 '16 at 04:32
-
This is a provider-specific directive. It may be supported by some backwards web hosts which still support PHP 5.2 (which has, by this point, been end-of-life for roughly eight years), but it is not generally applicable. – Nov 08 '18 at 18:58
-
worked :) view this page: https://www.bluehost.com/help/article/adding-handlers-to-change-your-php-version – Mohammad Masoudzadeh Dec 30 '22 at 08:07
0
I take it you want to process e.g. .php3 files with php 3.x.
You can't switch between php versions like this, but you might be able to do it by setting up a proxy server that distributes the query to one of several servers (one for each PHP version).
There might also be some apache hack that works by calling the cgi-bin mode php in FastCGI mode. See the linked answer for this.

Adder
- 5,708
- 1
- 28
- 56
-1
According to https://www.first2host.co.uk/f/change-php-version-php-ini/, adding the following line to your php.ini file will change you to PHP version 5.2:
AddHandler application/x-httpd-php52 .php
It only works if your host is first2host though, I reckon.

Paul Chris Jones
- 2,646
- 1
- 23
- 21
-
1This is a provider-specific directive, and will not work elsewhere. It's also effectively identical to the other answers already present on this question. (Unrelatedly, it's terrifying that a web host is still supplying a PHP version which has been end-of-life for nearly eight years.) – Nov 08 '18 at 18:56