PHP - htaccess - output_buffering
Asked Answered
B

3

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!

Bursarial answered 9/1, 2011 at 21:54 Comment(3)
Are those servers that return errors running a PHP version prior to 4.0.4?Interlink
No, they are all 5.2 or above.Quintonquintuple
Hey i was facing redirect issues i just add the above 2 line in .htaccess file and added ob_start() and flush() methods in my file Its works like a charm thanks :)Bradley
N
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.

Nernst answered 9/1, 2011 at 21:57 Comment(2)
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?Neel
@Neel no, Apache always throws a 500 error when it encounters an unknown command.Nernst
J
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

Jill answered 9/1, 2011 at 21:57 Comment(2)
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?Neel
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 500Jill
T
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
Teena answered 9/1, 2011 at 21:58 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.