Webmasters Stack Exchange is a question and answer site for pro webmasters. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I wanted to forbid some robots from doing certain things to my websites and decided to add a RewriteRule for that purpose.

The rule works when put in one of my <VirtualHost *:80> tag and looks like this:

RewriteEngine On
RewriteCond %{HTTP_USER_AGENT} libwww-perl
RewriteRule . - [F,L]

However, I wanted to apply that to all my websites instead of just one of them.

So with the newest version of Apache2 settings, I decided to put that code in the security.conf file. This file is defined under /etc/apache2/conf-available/... (and yes, I have a softlink from the /etc/apache2/conf-enabled/... directory.)

However, if the definition is only in the conf-available/security.conf files, it somehow gets ignored.

From the documentation, it says that these Rewrite* commands all work at server level!

Any idea of what I would be missing?

share|improve this question
Aside: the pattern . matches a single character, so the RewriteRule won't match requests for the document root. Change this to ^ or .* to match everything. – w3dk Nov 16 '15 at 12:13
up vote 3 down vote accepted

You need to add RewriteOptions Inherit to each virtual server.


share|improve this answer
Argh! I see that there is a new InheritDownBefore but I only have 2.4.6 and that one requires 2.4.8. Darn. I was hoping that it could be done without having to edit each virtual server... Too bad. I'll have to wait for the new version of Apache then. – Alexis Wilke Jun 3 '14 at 0:40

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.