Mobile app version of vmapp.org
Login or Join
Nickens628

: RewriteRule not working at server level? 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

@Nickens628

Posted in: #Apache2 #ModRewrite

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
RewriteCond %{REQUEST_METHOD} POST
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?

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Nickens628

1 Comments

Sorted by latest first Latest Oldest Best

 

@Hamaas447

You need to add RewriteOptions Inherit to each virtual server.

Reference: httpd.apache.org/docs/2.4/mod/mod_rewrite.html#rewriteoptions

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme