Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the '.htaccess is another option' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
.htaccess is another option
Authored by: sierratarn on Nov 12, '03 11:46:38AM

Another option is to put commands in .htaccess files. You have to ensure they are activated for the server but it does make it easy to seperate areas of your server. For example to run an old program where Register Globals must be on while developing your killer app in a seperate area with Register Globals turned off.



[ Reply to This | # ]
.htaccess is another option
Authored by: cteselle on Nov 12, '03 12:56:20PM
in the .htaccess file the entry would look like this:

php_flag register_globals on

[ Reply to This | # ]

There is yet a better way
Authored by: wallyfoo on Nov 13, '03 12:23:06AM

Better yet, if you have access to edit the php.ini file, you probably have access to edit your site's .conf file.

Given that, you should probably set a per-directory access option for your virtual host because
1. Virtual Host options are faster than parsing .htaccess files (read the Apache docs for why this is)
2. You'll need to check your .conf file anyway to make sure it has its AllowOverride option set to recognize .htaccess files at all.

So set the directory option.

For the sake of illustration, say you have a PHP-based forum installed in your document root in a folder called "forum" and it requires PHP register_globals on. Inside your Virtual Host you'd add this block of text:

<Directory "::absolute path to your document root::/forum">
php_flag register_globals on
</Directory>

Simple. Save the .conf file. sudo apachectl graceful. You're golden. Every PHP script inside that directory (and recursively within, I believe) will now recognize register_globals on.

Don't believe me? save

<? phpinfo(); ?>

to a file named, say, phpinfo.php within the forum directory and look on the page for register_globals.

Note, that syntax above for php_flag will not work on Apache 2. But if you're running Apache 2 on OS X, then you probably already know enough about Apache administration to not need this hint in the first place.

---
_____________________________
My other sig is really witty.



[ Reply to This | # ]
There is yet a better way
Authored by: WAW401 on Nov 13, '03 12:01:39PM

I agree that apache .conf files are the easiest way to do this. Also, the php configuration directives are not restricted to Directory containers, they can be used in a VirtualHost container. This is a great way to change settings for one php driven website without affecting all of your php driven websites.



[ Reply to This | # ]
There is yet a better way
Authored by: Bytesmiths on Dec 16, '03 10:25:57PM

In general, I agree with wallyfoo, but you might want to stick it in .htaccess if it is a short-term solution, while hunting down and clobbering your globals. That way, you can quickly turn it off an on for debugging, but you have to restart Apache every time you change http.conf.

---
: Jan Steinman, Bytesmiths



[ Reply to This | # ]