Change PHP version on server using either .htacces

2019-02-08 17:54发布

How can I change the PHP version to 5.2 on a server using either an .htaccess of php.ini file?

4条回答
仙女界的扛把子
2楼-- · 2019-02-08 18:09

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.

查看更多
【Aperson】
3楼-- · 2019-02-08 18:24

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.

查看更多
放我归山
4楼-- · 2019-02-08 18:27

Adding

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

to your .htaccess might work.

查看更多
叼着烟拽天下
5楼-- · 2019-02-08 18:32

This question was solveable through a simple google search:

There create a new file (or edit the existing one) called .htaccess and add the following line:

[...]

To switch to PHP 5.2: AddHandler application/x-httpd-php52 .php .php5 .php4 .php3

http://kb.siteground.com/article/How_to_have_different_Php__MySQL_versions.html

Can't see why this shouldn't work in your case as well, even though the article is host specific.

查看更多
登录 后发表回答