How to Fix .htaccess “php_flag not allowed here” Error

By | May 1, 2023

The php_flag directive can be used to set options that are specific to the php interpreter, directly from the .htaccess file. It is a good way to setup parameters across entire site, without having to repeat them in each php script or code.

The following code, turns off the register globals setting in php.

<IfModule mod_php5.c>
	#Turn off php register globals
	php_flag register_globals off
</IfModule>

However, sometimes the following error might show up in /var/log/apache/error.log file.

.htaccess: php_flag not allowed here

To fix this error, add the following directive to apache site/host configuration file.

AllowOverride FileInfo Options

The default site configuration file for apache is located at this location /etc/apache2/sites-available/default on most ubuntu/debian systems. You need to find the specific configuration file for your setup.

Here is an example

<Directory /var/www/>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride FileInfo Options
                Order allow,deny
                allow from all
        </Directory>
About Silver Moon

A Tech Enthusiast, Blogger, Linux Fan and a Software Developer. Writes about Computer hardware, Linux and Open Source software and coding in Python, Php and Javascript. He can be reached at [email protected].

Leave a Reply

Your email address will not be published. Required fields are marked *