UnixServerAdmin

Server Administration & Management

How to turn off & disable magic_quotes_gpc using .htaccess

It’s not only insecure but it inconveniently commands the use of PHP function stripslashes() every time you pull something from the database or when you get something from the client side. While most of the hosts out there are using factory settings of PHP that turn off magic_quotes_gpc by default, there are a few that don’t.

The value of magic_quotes_gpc cannot be set with the ini_set() function after PHP 4.2.3, some hosts enable custom php.ini in your home directory which you can use to set magic_quotes_gpc to 0 (zero) or false. Otherwise, you’d have to resort to .htaccess to set the PHP configuration values for your local directories.

To turn off magic_quotes and magic_quotes_gpc off in .htaccess, simply put these lines in the .htaccess file of your site / directory wherein you want magic_quotes or magic_quotes_gpc disabled:

=========================
php_value magic_quotes 0
php_flag magic_quotes off
php_value magic_quotes_gpc 0
php_flag magic_quotes_gpc off
=========================

Advertisements

May 9, 2011 - Posted by | htaccess | ,

3 Comments »

  1. This is a awesome write-up. Thank you for making the effort to detail this all out for folks. It is a great help!

    Comment by Miquel Hatten | June 15, 2011 | Reply

  2. I’d personally love to read all that you know regarding this subject. You only have scraped the surface of your knowledge on this which is apparent in the way you write. Have you considered devoting an entire internet site to ensure that others will not miss everything you have to say?

    Comment by fresh water | June 15, 2011 | Reply

  3. Continue to write regarding this matter. Right now there is often a increased need than you may anticipate for this type of advice and assistance. That which you discuss is useful to the person who is looking for the concepts that you’ve put together.

    Comment by great water filters | June 16, 2011 | Reply


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: