Page 1 of 1

Turn register_globals off on shared server

Posted: Tue May 24, 2005 10:55 pm
by charp
I teach a basic web design class at my high school and I include a bit of PHP. On our shared hosting site, register_globals is turned on. I'd like to turn it off to force my student into coding for that sort of environment. I did some research on the PHP site and found this:
If you're under an Apache environment that has this option enabled, but you're on shared hosting so have no access to php.ini, you can unset this value for your own site by placing the following in an .htaccess file in the root:

php_flag register_globals 0

The ini_set() function actually accomplishes nothing here, since the variables will have already been created by the time the script processes the ini file change.

And since this is the security chapter, just as a side note, another thing that's helpful to put into your .htaccess is:

<Files ".ht*">
deny from all
</Files>
The directions seem straight forward enough, but I have no experience with configuring PHP by any method and I'm wondering if there's anything else I should be considering or worried about.

Comments? Hints? Suggestions? Thanks in advance!

Posted: Wed May 25, 2005 10:15 am
by Sphen001
Well, first you should talk to your host. It's possible that they will turn off globals if you ask them to. If they won't change it for you, just try what you posted below.

Hope this helps :D

Sphen001