Changing PHP flags in .htaccess

I have a domain set up to run PHP as CGI, and I’m wanting to define PHP’s register_globals flag as off. So, I’ve set a .htaccess file in the served root directory, containing:

php_flag register_globals off

…which should do the trick. But nooooo, phpinfo() indicates globals are stubbornly still on. All the references I can find online suggest this should work. Any ideas?

Thanks in advance.

This won’t work, unfortunately. I’m not sure exactly why… I’ll see if there’s anything we can do to get this to work.

Believe me - we’re really hoping to figure out some way to turn of register_globals /everywhere/. Since this is the default in PHP5, hopefully vendors will start writing code that doesn’t rely on it.

I’d assume the technical reason is that directives in .htaccess files are only visible to Apache modules. Since PHP is running as a CGI, it’s more or less separate from Apache, so it can’t “see” the php_value directive.

You could get around that problem by running PHP as an Apache module, or compiling your own PHP so you’d have your own php.ini. Or just be careful to initialise all variables when writing code.

I wonder if it would be possible to add something to .htaccess that would call Dreamhost’s existing PHP CGI with a command-line switch that would point it to a different php.ini?

Thanks for the replies, folks - it’s good to have confirmation I’m not being a complete klutz about this!