Setting a PHP version per domain/directory on a shared server Skriv ut

  • php, version
  • 1

You can set a custom PHP version per domain or directory by creating a .htaccess file containing the following text or by placing it at the top of an existing .htaccess file (choose the appropriate version):

# PHP 5.3 

 

<FilesMatch "\.(php4|php5|php3|php2|php|phtml)$">

SetHandler application/x-httpd-alt-php53___lsphp

</FilesMatch>

 

# PHP 5.4 

 

<FilesMatch "\.(php4|php5|php3|php2|php|phtml)$">

SetHandler application/x-httpd-alt-php54___lsphp

 

</FilesMatch>

 

# PHP 5.5 

 

<FilesMatch "\.(php4|php5|php3|php2|php|phtml)$">

SetHandler application/x-httpd-alt-php55___lsphp

 

 

</FilesMatch>

 

# PHP 5.6 

 

<FilesMatch "\.(php4|php5|php3|php2|php|phtml)$">

SetHandler application/x-httpd-alt-php56___lsphp

 

 

</FilesMatch>

 

# PHP 7.0 

 

<FilesMatch "\.(php4|php5|php3|php2|php|phtml)$">

SetHandler application/x-httpd-alt-php70___lsphp

 

 

</FilesMatch>

 

# PHP 7.1 

 

<FilesMatch "\.(php4|php5|php3|php2|php|phtml)$">

SetHandler application/x-httpd-alt-php71___lsphp

 

 

</FilesMatch>

 

# PHP 7.2 

 

<FilesMatch "\.(php4|php5|php3|php2|php|phtml)$">

SetHandler application/x-httpd-alt-php72___lsphp

 

 

</FilesMatch>

 

# PHP 7.3 

 

<FilesMatch "\.(php4|php5|php3|php2|php|phtml)$">

SetHandler application/x-httpd-alt-php73___lsphp

 

 

</FilesMatch>

 

# PHP 7.4 

 

<FilesMatch "\.(php4|php5|php3|php2|php|phtml)$">

SetHandler application/x-httpd-alt-php74___lsphp

 

 

</FilesMatch>

 

# PHP 8.0 

 

<FilesMatch "\.(php4|php5|php3|php2|php|phtml)$">

SetHandler application/x-httpd-alt-php80___lsphp

 

 

</FilesMatch>

 

# PHP 8.1 

 

<FilesMatch "\.(php4|php5|php3|php2|php|phtml)$">

SetHandler application/x-httpd-alt-php81___lsphp

 

 

</FilesMatch>

 

 

 

As with any .htaccess file it works recursively so will affect all directories below the one it's in, if you need anything below to use a different version you can place another .htaccess file with the appropriate version in it.


Hjälpte svaret dig?

«Tillbaka