how to change php version in htaccess in server
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
change php version using .htaccess in cpanel is not working
Finally, AddHandler application/x-httpd-php70 .php
worked for me. Thank you!
Change PHP version on server using either .htaccess or php.ini
Adding
AddHandler application/x-httpd-php52 .php .php5 .php4 .php3
to your .htaccess might work.
PHP: Composer uses PHP version older than the used version (on shared hosting)
Note that .htaccess
only affects the Apache configuration. When accessing the server via SSH the file is completely ignored/useless.
Some providers install multiple versions of PHP, making it available by typing php7.3
, and the php
is a simple alias to the current default version. Probably the composer is set up in a way to use a different version of the default (not sure how/why) while your ssh session is using another.
Since your php -v
is reporting the desired version. I would suggest downloading composer.phar
and running it locally via php composer.phar ...
instead of relying on the currently systemwide installed composer.
Multiple php versions with .htaccess files
You can use conditional php version by configuring the htaccess as explained in this post. A list of PHP versions can be found in this post.
Related Topics
Array_Splice() For Associative Arrays
Notice: Array to String Conversion In
PHPmailer - Ssl3_Get_Server_Certificate:Certificate Verify Failed
Why Are $_Post Variables Getting Escaped in PHP
PHP Array Merge Two Arrays on Same Key
How to Successfully Rewrite Old MySQL-PHP Code With Deprecated MySQL_* Functions
Including PHP File from Another Server With PHP
PHP: How to Read a .Txt File from Ftp Server into a Variable
PHP Password_Hash(), Password_Verify()
Why Is Register_Globals So Bad
PHP Curl Not Working - Wamp on Windows 7 64 Bit
How to Read Last Lines (I.E. "Tail") from a File Using PHP
Rebase Array Keys After Unsetting Elements
How to Locate the PHP.Ini File (Xampp)
Create Ini File, Write Values in PHP