I have been trying to add rules like the following to the /etc/apache2/apache.conf file but they havent been noticed, whereas if I add them to the individual .htaccess files they are obeyed and anyone trying to access a readme.html file will be redirected.. I have added the followng rules but none of they are noticed including the ServerSignature ServerTokens ones.. the OS is debian 7 wheezy
ServerSignature Off
ServerTokens Prod
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule readme\.html? - [NC,F]
RewriteRule changelog\.txt? - [NC,F]
</IfModule>
Best Answer
If you have virtual hosts, note that by default Rewrite configurations are not inherited by virtual hosts. In order to "inherit" the directives in the vHost configurations, each vHost configuration needs:
See the Apache documentation for the
RewriteOptions
directive for more detail.To deny these two files server wide, without using
mod_rewrite
, you can also use a<FilesMatch>
container with the appropriate access control directive.For Apache 2.4: