Welcome, Guest. [ Log In ]
Question   Turning off register_globals for a specific domain/directory
Search KBase

Top 5 in this Area:
1. What's the difference between PHP-CGI and PHP as an Apache module?
2. PHP Security
3. Compiling your own custom PHP
4. Can I run a phpbb forum (message board) on my site?
5. Do you support this PHP module or extension?

Turning off register_globals for a specific domain/directory
Some scripts require that the register_globals setting be turned off in order to work. By default, register_globals is enabled on all DreamHost-hosted domains. UNLESS you have php5 on.. for php5 register_globals is off and you can't enable it.

In order to turn this setting off, create a file named ".htaccess" in the directory you want this setting to affect. If you want it to affect an entire domain name, create the ".htaccess" file in the root directory for that domain (usually, this directory is named after the domain). Within the file, place the following line:

php_flag register_globals off

Note that for this to work, you will need to uncheck the "Run PHP as CGI" setting option for your domain name by editing it in the web panel, here:


This setting could take a few hours to take effect.

Last updated: Aug 01, 2005.

User Post (2005-08-28 07:00:19 by astrobola)
Hi people.
¿How can I set magic_quotes_gpc on ? i think is usefull, but i see it is disabled in the dh server.
User Post (2005-02-25 23:07:32 by gottalovett)
If you sitll want to run PHP as CGI, but want to have the effect of register_gobals being turned off, you can run this script below (c/o Egghead as posted on SitePoint):

// Unregister Globals
function unregister_globals()
   // Save the existing superglobals first
   $GET = $_GET;
   $POST = $_POST;
   if (isset($_SESSION))
   $FILES = $_FILES;
   $ENV = $_ENV;

   // Unset the $GLOBALS array (clear all)
   foreach($GLOBALS as $key => $value)
      if ($key != 'GLOBALS')

   // Re-assign the saved superglobals again
   $_GET = $GET;
   $_POST = $POST;
   if (isset($SESSION))
   $_FILES = $FILES;
   $_ENV = $ENV;