Running a different php version for only part of my website

Update: for newer accounts use :

php-script

instead of

custom-php

You can also set the php version on a per-directory basis (for testing, development, etc.). To run a different php version on part of your site, perform the following.

Create a .htaccess file :

.htaccess

(the leading dot is required)

inside the top level directory for which you want to change the php version.

Inside the file put the lines:

AddHandler custom-php .php .pcgi .phtml .inc .phtml~ .php~ .inc~ .html~
Action custom-php /cgi-sys/php5.6

some users may need the following instead:

Action php-script /cgi-sys/php7
AddHandler php-script .php .maml .html .css .mss .pcgi .phtml .inc .phtml~ .php~ .inc~ .html~

Replace php5.6 with which ever version you want to run
You can also add other file extensions to the list in the first line.

Depending upon the server and current php verison, you can choose from among:

/cgi-sys/php8.1
/cgi-sys/php7
/cgi-sys/php7.4
/cgi-sys/php5.6

etc.

In general, many php<major-version>.<minor-version> will work. The possible versions may vary. Contact support if a version you need is missing.

Historical Notes:

The following no longer is allowed. This is kept for historical reference:

To run a part of your site as mod_php, add this line to a .htaccess in the directory you want to run as mod_php :


AddHandler application/x-httpd-php .php3 .phtml .php .php4 .php~ .php3~ .php4~ .phtml~ .inc .inc~

Leave a Reply

Your email address will not be published. Required fields are marked *