Apache .htaccess <Directory not allowed here Apache .htaccess <Directory not allowed here apache apache

Apache .htaccess <Directory not allowed here


<Directory> directive is not allowed in .htaccess and for meeting your requirements you don't even need this in .htaccess.

You can use this rule in site root (parent) .htaccess:

RewriteEngine OnRewriteCond %{QUERY_STRING} !(?:^|&)test=yes(?:&|$) [NC]RewriteRule ^foo/(.*)$ bar/$1?test=yes [NC,QSA,L]


<Directory.. is not allowed in .htaccess according to the manual. You can have it only in server config and virtual host. You should use mod_rewrite instead.


Short answer: Just delete the .htaccess file and your error.log problem will vanish.

Longer answer:

I started getting the same message in my C:\xampp\apache\logs\error.log file earlier today. The error began suddenly (after years of using localhost without a hitch) and coincided with a "500 server error" when I tried to start localhost.

The content of the .htcaccess file (which had appeared in my /Sites directory for the first time today) was:

<Directory>  AllowOverride All  Order allow,deny</Directory>

As others have noted in relation to similar .htcaccess questions, the file is not generally necessary.

I therefore simply deleted the .htcaccess file, which instantly solved the problem. Immediately localhost started working again, and the error vanished from the logs!