How to Change PHP Version in Htaccess in Server

If you have a website running on a server, you may need to change the PHP version that it uses to run.

This can be necessary if you need to use a specific version of PHP for your website to work properly, or if you want to update your website to a newer version of PHP for security or performance reasons.

Changing the PHP version on a server can be done using the .htaccess file.

In this tutorial, we will go over how to change the PHP version in .htaccess on a server.


.htaccess

The .htaccess file is a configuration file used by Apache servers to control how the server handles requests for specific files and directories.

This file can be used to control various aspects of the server, including the PHP version that is used to run a website.

By making changes to the .htaccess file, you can change the PHP version that your website uses.

How to Change the PHP Version in .htaccess

To change the PHP version in .htaccess, you need to add the following code to the file:

AddHandler application/x-httpd-php70 .php

In the above code, replace “70” with the version of PHP you want to use (for example, replace it with “72” if you want to use PHP 7.2).

Note: Before making any changes to the .htaccess file, it is important to make a backup of the file in case something goes wrong.


Conclusion

Changing the PHP version in .htaccess is a simple process that can be done by adding a few lines of code to the file.

This can be useful if you need to use a specific version of PHP for your website to work properly, or if you want to update your website to a newer version of PHP for security or performance reasons.

By following the steps outlined in this tutorial, you can change the PHP version in .htaccess on your server with ease.