Updated: 15 November 2026 · Applies to: DirectAdmin with PHP 5.4 and later (tested with PHP 8.3 and 8.4)
There is nothing to disable: magic_quotes_gpc was removed from PHP in version 5.4, so every PHP version a DirectAdmin server runs today already behaves as if it were off. What you should do instead is remove any old line that still tries to set it, because on current PHP that line causes errors rather than doing nothing.
What happens if the setting is still there
We tested each place the setting is usually found:
- In php.ini (or a
-doption): PHP 8.4 stops with a fatal error before running any script.
PHP Fatal error: Directive 'magic_quotes_gpc' is no longer available in PHP in Unknown on line 0
- In .htaccess as
php_flag, with PHP-FPM: Apache returns a 500 Internal Server Error for the whole folder. PHP-FPM is common on DirectAdmin servers, and according to DirectAdmin it does not read PHP settings from .htaccess at all. The Apache error log shows:
/var/www/html/mq/.htaccess: Invalid command 'php_flag', perhaps misspelled or defined by a module not included in the server configuration
- In .htaccess with Apache's PHP module (mod_php): PHP 8.3 ignored the line and the page loaded, so it is harmless there but still useless.
- In old PHP code: scripts that call
get_magic_quotes_gpc()fail on PHP 8, because the function itself was removed in PHP 8.0.
Fatal error: Uncaught Error: Call to undefined function get_magic_quotes_gpc()
How to clean it up
- Search your website files for the setting. Replace
aliceandexample.comwith your username and domain.
grep -rn --include=.htaccess --include=.user.ini --include=php.ini magic_quotes /home/alice/domains/example.com/public_html
Output (example):
/home/alice/domains/example.com/public_html/shop/.htaccess:1:php_flag magic_quotes_gpc Off
- Delete each
magic_quotes_gpcline it finds (in DirectAdmin's File Manager or over SSH). Keep a copy of the file first. - If you manage the server, check the server-wide PHP configuration too. According to DirectAdmin, it lives in
/usr/local/phpXX/lib/php.iniand the/usr/local/phpXX/lib/php.conf.d/folder, where XX is the PHP version (for examplephp83).
grep -rn magic_quotes /usr/local/php*/lib/
- Reload the site. A 500 error caused by the line should be gone; if not, see Internal Server Error or Error 500.
If a script still asks for magic quotes
Software that needs magic quotes, or calls get_magic_quotes_gpc(), was written for PHP 5.3 or older and has had no security updates for years. Update it to a current release or replace it. Turning on an old PHP version just to run it is not safe on a public server. To pick a current PHP version for your domain, see How to Change PHP version on Directadmin Server?.
Official documentation: PHP manual, get_magic_quotes_gpc and DirectAdmin, PHP options.