Apache RewriteRule ignoring RewriteCond?

Posted by winsmith on Server Fault See other posts from Server Fault or by winsmith
Published on 2010-05-26T12:29:41Z Indexed on 2010/05/26 12:33 UTC
Read the original article Hit count: 148

Filed under:
|
|

So I have an Apache running on OSX Server 10.4 (don't ask) with multiple sites. In 0002_[example.com].conf, I have this bit of code:

<Directory "/Library/WebServer/Documents/secret/">
    RewriteEngine On
    RewriteCond %{REMOTE_ADDR} !^137\.250\.
    RewriteRule .* /messages/secret.html
</Directory>

However, in this configuration, the RewriteCond always seems to evaluate to false, since the secret directory gets shown even if the client's address does not begin with 137.250.

If I change the config to this

<Directory "/Library/WebServer/Documents/secret/">
    RewriteEngine On
    RewriteRule .* /messages/secret.html
    RewriteCond %{REMOTE_ADDR} !^137\.250\.
</Directory>

the condition either does not get evaluated at all or always evaluates to true. Either way, all clients get blocked.

What am I doing wrong?

© Server Fault or respective owner

Related posts about apache

Related posts about osx