Forum Moderators: phranque

Message Too Old, No Replies

PHP version in .htaccess

         

qimqim

9:32 pm on Mar 7, 2015 (gmt 0)

10+ Year Member Top Contributors Of The Month



Hi

I changed Hosts and had a problem inasmuch as php files did not open correctly (instead they downloaded the code). It turned out that the beginning of the .htaccess file was like this

#Use PHP5.4 Single php.ini as default

AddHandler application/x-httpd-php54s .php

#
AddType text/x-component .htc


and the problem resulted from different versions of php used by the two Hosts. The current one uses 5.5.21, while the old 5.4.24

Right now, the files are opening properly simply by deleting the line, but as I cannot remember why it was put there in the first place... should I amend the line to

AddHandler application/x-httpd-php5.5s .php

lucy24

12:32 am on Mar 8, 2015 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



should I amend the line to
AddHandler application/x-httpd-php5.5s .php

Only if you're certain that this is the actual name of the file used-- and you're certain that you will always be up-to-date on version numbers.

The problem you observed came from giving too much information, rather than too little. The server looked for a specific file or function that didn't exist; when it couldn't find that, it went into fallback mode, which is generally "show the raw text" or "download the file".

It is very very unlikely that you would want a page to display raw php code instead of executing it. If the appropriate file or function suddenly disappeared, you would probably want your pages to fail outright rather than expose your raw code to the world. In my case, primarily because I would perish from shame if anyone saw my php.

In general it's safest not to say anything and let the server sort it out. Your host undoubtedly has a control-panel setting where you can choose a php version number. If the exact php version is important, you may be better off with a VPS, where you can have full control. But this is rarely the case.

qimqim

6:52 am on Mar 8, 2015 (gmt 0)

10+ Year Member Top Contributors Of The Month



Thank you Lucy. That's what happened amd I understand that yiou feel it is better to leave the line out altogether. But if I choose to leave it in what is the format in the new server?

lucy24

7:24 am on Mar 8, 2015 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I'd check with the host to be sure. A server is not going to give you the benefit of the doubt when it comes to a misplaced decimal point ("55" vs. "5.5"). If it's a major host, they may already have a wiki or FAQ page that spells out the exact form so you don't have to pester a human.

qimqim

7:37 am on Mar 8, 2015 (gmt 0)

10+ Year Member Top Contributors Of The Month






So you don't have to pester a human


Oh, oh... sorry!


It was the Host that discovered the reason for the php files not opening properly, and they simply put a # in fron of the line.


I wasn't exactly referring to the decimal point, rather to the new version.

What would you write in that line if it was necessary?

AddHandler application/x-httpd-php5.5s .php


Should the "s" in 5.5s remain there?

lucy24

8:33 am on Mar 8, 2015 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Oh, oh... sorry!

Haha, I meant a human at the hosting company.

I wasn't exactly referring to the decimal point
....
Should the "s" in 5.5s remain there?

Well, it's really the same question. The line is only meaningful if it points to something that the server is actually able to do, whether that be "php55" or "php5.5s" or some other permutation entirely. That's why I suggested asking the host. What version do you get if you just say

application/x-httpd-php

? Next to saying nothing, that would be the preferred form.

qimqim

9:09 am on Mar 8, 2015 (gmt 0)

10+ Year Member Top Contributors Of The Month



Ok, thanks

I'll take it up with the server.