Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

KarolGil's avatar

Php version and .htaccess

I have this server structure.

/ - php version 5.6 set for the entire server as default

/.htaccess

<FilesMatch "\ .php $">
SetEnv CGI_HANDLER php73
</ FilesMatch>

/laravel/.htaccess

AddType application / x-httpd-php72 .php5 .php4 .php .php3 .php2 .phtml

Can anyone explain me why and how it works? I mean, first of all, writing to the file /laravel/.htaccess. Because when the /laravel/.htaccess file is empty, then the laravel script does not work.

The server / hosting has different php versions to choose from 5.6, 7.0, 7.1, 7.2, 7.3, 7.4

This situation applies to laravel version 5.8

0 likes
14 replies
KarolGil's avatar

@hayk_d I know that. Describes the situation I encountered and I ask why and how it works?

TheRealHyveMind's avatar

Firstly, consider updating your version of Laravel if you intend to be working on this project in the long term. Laravel 5.8 is fast approaching the end of its life.

https://laravel.com/docs/5.8/releases#support-policy

As for the issue, I have to admit I'm a little confused as to what the problem is. Laravel 5.8 requires as a minimum PHP 7.1 or greater.

https://laravel.com/docs/5.8/installation#server-requirements

Are you asking how to choose which version of PHP you're using on your server? If that is the case, we'll need to know more about the server you're using, and your provider might be able to help too.

KarolGil's avatar

@alecweekes The server has the php 5.6 "/ - php 5.6" version set, the php files in /.htaccess are forced to version 7.3, the version 7.2 forced for laravele / laravel / htaccess

And my question is why and how does it work?

TheRealHyveMind's avatar

Sorry but I'm not entirely sure what it is you're asking specifically.

If you're able to make the changes you'll simply need to upgrade / update any PHP versioning that is occuring to reflect the minimum requirement of Laravel 5.8.

As I said though, consider updating to Laravel 6+ to ensure on-going support, updates and security fixes.

Hopefully this'll help a little bit; https://www.tecmint.com/install-different-php-versions-in-ubuntu/

KarolGil's avatar

@alecweekes

I ask, how exactly does this entry work?

/laravel/.htaccess

AddType application / x-httpd-php72 .php5 .php4 .php .php3 .php2 .phtml
KarolGil's avatar

@alecweekes

It was. And when this entry is in /laravel/.htaccess then the script / laravel works fine. However, when it is not present, the script / laravel does not work.

Do you know why this happens?

KarolGil's avatar

Only from the laravel requirements and from what php versions I have available on the server.

Only further question is, why this record /laravel/.htacces skypt / laravel works, and does not work without it?

Snapey's avatar

the setting in htaccess is so that different websites on the same server can use different php versions

siangboon's avatar

you are literally asking why a php file with <?php tag can run php code, without it php code will not work...

KarolGil's avatar

I am asking more how .htaccess affects the server, that it sets and uses the given version of php in a given directory.

/catalogA - 5.6 /catalogB - 7.0

And what is required for this? Only installed php versions on the server or something else?

Please or to participate in this conversation.