How to choose php version in .htaccess

0

I would like to install my PHP web application on a service that has two PHP versions, 4 and 5. I need PHP5, and I don't have access to httpd.conf due to server restrictions. How can I tell the Apache web server to choose PHP5 for this folder?

The server is Linux.

orezvani

Posted 2013-09-07T06:07:16.703

Reputation: 157

1http://docs.1h.com/How_to_switch_PHP_versions – Soosh – 2013-09-07T07:22:22.247

how can I mark the question as solved? – orezvani – 2013-09-07T11:59:39.413

Answers

1

You can switch between your installed PHP versions in several ways. If you are restricted to use .htacess, you may add a handler in your .htacess file. For example if you want to use PHP 4, you can add the following code to your .htacess file:

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

For PHP 5.0 you can use:

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

For PHP 5.1 you can use:

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

Similarly for PHP 5.2 and 5.3. If you want PHP 5.2 with Suhosin patch use:

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

The answer can be found in the following links:

https://stackoverflow.com/questions/12105632/change-php-version-on-server-using-either-htaccess-or-php-ini

http://docs.1h.com/How_to_switch_PHP_versions

orezvani

Posted 2013-09-07T06:07:16.703

Reputation: 157

At the moment, this post is essentially only a link. To make sure the answer remains useful even if the link breaks, please edit it to include the relevant information. (Your answer was discovered in an effort to repair or remove old link-only answers.)

– Ben N – 2016-01-10T04:48:48.547

0

Gaurang P

Posted 2013-09-07T06:07:16.703

Reputation: 121

Please quote the essential parts of the answer from the reference link(s), as the answer can become invalid if the linked page(s) change. – DavidPostill – 2015-01-21T11:52:40.763

At the moment, this post is essentially only a link. To make sure the answer remains useful even if the link breaks, please edit it to include the relevant information. (Your answer was discovered in an effort to repair or remove old link-only answers.)

– Ben N – 2016-01-10T04:48:41.917