Home  >  Article  >  Backend Development  >  How to Change PHP Version on a Shared Server Using .htaccess?

How to Change PHP Version on a Shared Server Using .htaccess?

Mary-Kate Olsen
Mary-Kate OlsenOriginal
2024-10-24 04:29:01139browse

How to Change PHP Version on a Shared Server Using .htaccess?

Changing PHP Version on a Shared Server Using .htaccess

It can be frustrating to work with a different PHP version on the server than on the local machine. However, it is possible to change the PHP version on a shared server using the .htaccess file.

To do this, you can use the AddHandler directive followed by the desired PHP version. Here's how:

  • PHP 4.4:

    AddHandler application/x-httpd-php4 .php
  • PHP 5.0:

    AddHandler application/x-httpd-php5 .php
  • PHP 5.1:

    AddHandler application/x-httpd-php51 .php
  • PHP 5.2:

    AddHandler application/x-httpd-php52 .php
  • PHP 5.3:

    AddHandler application/x-httpd-php53 .php
  • PHP 5.4:

    AddHandler application/x-httpd-php54 .php
  • PHP 5.5:

    AddHandler application/x-httpd-php55 .php
  • PHP 5.6:

    AddHandler application/x-httpd-php56 .php
  • PHP 7:

    AddHandler application/x-httpd-php7 .php
  • PHP 7.1:

    AddHandler application/x-httpd-php71 .php

Remember to add these directives to your .htaccess file and save the changes. The server will now use the specified PHP version for the files that match the .php extension.

The above is the detailed content of How to Change PHP Version on a Shared Server Using .htaccess?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn