Turn register_globals off on shared server

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
charp
Forum Commoner
Posts: 85
Joined: Sun Oct 26, 2003 3:00 pm
Location: Rancho Cucamonga, Calif. USA

Turn register_globals off on shared server

Post 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!
Sphen001
Forum Contributor
Posts: 107
Joined: Thu Mar 10, 2005 12:24 pm
Location: Land of the Beaver

Post 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
Post Reply