2

I currently have a virtualhost within Apache that is using mod_cband and mod_rewrite. I am using mod_cband to limit the number of connections per remote user. When this limit is exceeded, it is supposed to return 503 Service Unavailable which is the mod_cband default.

If the limit is not exceeded then mod_rewrite should rewrite the URL according to the rules I have specified.

Unfortunately, mod_rewrite seems to take some sort of priority over mod_cband as the rewrite occurs even when the limit is exceeded and 503 Service Unavailable is never returned.

Is there anyway to force mod_cband to be applied before mod_rewrite? Config is as follows:

<VirtualHost *:80>
    ServerName a.domain.com
    ServerAdmin [email protected]

    CBandRemoteSpeed 1024 1 10

    RewriteEngine on
    # Some other rewrite rules.

    RewriteRule (.*) https://a.domain.com? [R]

    ...

</VirtualHost>

1 Answer 1

3

Move the mod_rewrite processing into a later phase by putting the rules in .htaccess instead.

3
  • Which .htaccess file should I put my catch all rule in so that it is used for every request? Jun 15, 2012 at 23:16
  • The one right in DocumentRoot. Jun 16, 2012 at 0:16
  • Worth noting: doing this in a <Directory> block works just as well, without the performance (and potentially security) issues inherent in .htaccess files. Jun 17, 2012 at 6:03

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .