Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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 webmaster@domain.com

    CBandRemoteSpeed 1024 1 10

    RewriteEngine on
    # Some other rewrite rules.

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

    ...

</VirtualHost>
share|improve this question

1 Answer 1

up vote 3 down vote accepted

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

share|improve this answer
    
Which .htaccess file should I put my catch all rule in so that it is used for every request? –  DanielGibbs Jun 15 '12 at 23:16
    
The one right in DocumentRoot. –  Ignacio Vazquez-Abrams Jun 16 '12 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. –  Shane Madden Jun 17 '12 at 6:03

Your Answer

 
discard

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.