How to Change PHP Version in Htaccess in Server

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



Leave a reply



Submit