how to change php version in htaccess in server
Solution 1:
To switch to PHP 4.4:
AddHandler application/x-httpd-php4 .php
To switch to PHP 5.0:
AddHandler application/x-httpd-php5 .php
To switch to PHP 5.1:
AddHandler application/x-httpd-php51 .php
To switch to PHP 5.2:
AddHandler application/x-httpd-php52 .php
To switch to PHP 5.3:
AddHandler application/x-httpd-php53 .php
To switch to PHP 5.4:
AddHandler application/x-httpd-php54 .php
To switch to PHP 5.5:
AddHandler application/x-httpd-php55 .php
To switch to PHP 5.6:
AddHandler application/x-httpd-php56 .php
To switch to PHP 7:
AddHandler application/x-httpd-php7 .php
To switch to PHP 7.1:
AddHandler application/x-httpd-php71 .php
Solution 2:
To switch to PHP 4.4:
AddHandler application/x-httpd-php4 .php .php4 .php3
To switch to PHP 5.0:
AddHandler application/x-httpd-php5 .php .php5 .php4 .php3
To switch to PHP 5.1:
AddHandler application/x-httpd-php51 .php .php5 .php4 .php3
To switch to PHP 5.2:
AddHandler application/x-httpd-php52 .php .php5 .php4 .php3
To switch to PHP 5.3:
AddHandler application/x-httpd-php53 .php .php5 .php4 .php3
To switch to PHP 5.4:
AddHandler application/x-httpd-php54 .php .php5 .php4 .php3
To switch to PHP 5.5:
AddHandler application/x-httpd-php55 .php .php5 .php4 .php3
To switch to the secure PHP 5.2 with Suhosin patch:
AddHandler application/x-httpd-php52s .php .php5 .php4 .php3
Solution 3:
Note that all above answers are correct for Apache+mod-php setups. They're less likely to work with more current PHP-FPM setups. Those can typically only be defined in VirtualHost section, not .htaccess.
Again, this highly depends on how your hoster has configured PHP. Each domain/user will typically have it's own running PHP FPM instance. And subsequently a generic …/x-httpd-php52
type will not be recognized.
See ServerFault: Alias a FastCGI proxy protocol handler via Action/ScriptAlias/etc for some overview.
For Apache 2.4.10+/mod-proxy-fcgi configs you might be able to use something like:
AddHandler "proxy:unix:/var/run/php-fpm-usr123.sock|fcgi://localhost" .php
Or SetHandler
with name mapping from your .htaccess
. But again, consulting your hoster on the concrete FPM socket is unavoidable. There's no generic answer to this on modern PHP-FPM setups.
Solution 4:
Try this to switch to php4:
AddHandler application/x-httpd-php4 .php
Upd. Looks like I didn't understand your question correctly. This will not help if you have only php 4 on your server.
Solution 5:
just FYI in GoDaddy it's this:
AddHandler x-httpd-php5-3 .php