6

I have the following code in an htaccess file in my application root to turn output buffering on.

php_value output_buffering On
php_value output_handler mb_output_handler

On some servers it causes a 500 internal error, on others it works fine. Does anyone know why it sometimes causes an error. Is there a different way to do this?

Thank you!

moinudin
  • 134,091
  • 45
  • 190
  • 216

3 Answers3

4

You can use this syntax only if PHP is running as an Apache module.

The 500 errors probably come up on servers where this is not the case.

For total certainty, look into the server's error.log file for a detailed error message.

Pekka
  • 442,112
  • 142
  • 972
  • 1,088
  • Even if we take that the server does not run PHP as Apache module, **Why would it throw a 500 error?** Isn't the contents of the .htaccess file merely ignored? – Pacerier Feb 07 '18 at 14:35
  • @Pacerier no, Apache always throws a 500 error when it encounters an unknown command. – Pekka Feb 07 '18 at 17:00
2

Those directives work only if PHP is installed as a module. On other servers it will result in 500, since they will be invalid directives

German Rumm
  • 5,782
  • 1
  • 25
  • 30
  • Even if we take that the server does not run PHP as Apache module, Why would it throw a 500 error? Isn't the contents of the .htaccess file merely ignored? – Pacerier Feb 07 '18 at 14:36
  • No, contents are evaluated as directives, and if PHP module is not there, Apache would not know how to interpret "php_value" directive, so it will fail with 500 – German Rumm Feb 13 '18 at 15:53
2

Not sure, but i think the error is caused by the first line.

Use php_flag for On/Off True/False switches, like this:

php_flag output_buffering On
Richard Tuin
  • 4,484
  • 2
  • 19
  • 18