Change PHP variables using .htaccess

If you need to change the way your PHP is working you can do that using .htaccess.
Please, note that not all PHP options can be changed using .htaccess.
A list of options that can be changed using .htaccess file can be found at:

The ones that can be changed with .htaccess are the ones marked with: PHP_INI_PERDIR or PHP_INI_ALL. The ones marked as PHP_INI_SYSTEM cannot be changed via .htaccess files.

The syntax is pretty simple:

php_flag [variable_name] [value]

For example if you need to turn off register_globals:

php_flag register_globals off

If you need to change the PHP include path:

php_value include_path ".:/usr/local/lib/php:/your_include/path"

The include_path string starts with a dot “.” And then each additional path is separated with a semi colon.   (e.g. .:/path1:/path2:/path3)

Leave a comment