Magic Quotes is a procedure that instantly escapes incoming data to the PHP script. It’s better to code with magic quotes off instead to escape the data at runtime, as required. We can simply turn OFF magic_quotes and magic_quotes_gpc from the php configuration file itself.
1. Disabling Magic Quotes from PHP conf file.
SSH to your server and find the php.ini file by using the below command.
php --ini Configuration File (php.ini) Path: /usr/local/lib Loaded Configuration File: /usr/local/lib/php.ini Scan for additional .ini files in: (none) Additional .ini files parsed: (none)
From php.ini file we can directly disable magic_quotes and magic_quotes_gpc. Open php.ini file using your favorite editor and make the changes as follows:
; Magic quotes for incoming GET/POST/Cookie data. magic_quotes_gpc = Off ; Magic quotes for runtime-generated data, e.g. data from SQL, from exec(), etc. magic_quotes_runtime = Off ; Use Sybase-style magic quotes (escape ' with '' instead of \'). magic_quotes_sybase = Off
But in shared environment, This is not good practice to disable it. In such situation we can disable magic_quotes and magic_quotes_gpc by using .htaccess file for a specific domain.
2. Disable Magic Quotes using .htaccess file
It’s a very simple but useful way to disable magic_quotes and magic_quotes_gpc with .htaccess file in a shared server environment.
Create a .htaccess file under the public_html folder of the domain that needs to disable magic_quotes and magic_quotes_gpc and put these lines in htaccess file.
php_value magic_quotes 0 php_flag magic_quotes off php_value magic_quotes_gpc 0 php_flag magic_quotes_gpc off
That’s all you have to do, Now you know how to Disable Magic Quotes using .htaccess file . You also like to know how to Disable Magic Quotes in Joomla , Please check that and also Give your opinion below if you experience any issues or to discuss your ideas and experiences.