Forum Moderators: phranque
R=403 says "redirect and issue a 403 status code". It's not a 403 Forbidden.
RewriteCond %{REQUEST_URI} ^/wp-login\.php(.*)$ [OR]
RewriteCond %{REQUEST_URI} ^/wp-admin$
<snip>
RewriteRule ^(.*)$ - [F]
Actually it is.
Any valid HTTP response status code may be specified, using the syntax [R=305], with a 302 status code being used by default if none is specified. The status code specified need not necessarily be a redirect (3xx) status code. However, if a status code is outside the redirect range (300-399) then the substitution string is dropped entirely, and rewriting is stopped as if the L were used.
Using the [F] flag causes the server to return a 403 Forbidden status code to the client.
...
When using [F], an [L] is implied - that is, the response is returned immediately, and no further rules are evaluated.
RewriteRule ^(.*)$ - [R=403,L] RewriteRule .* - [R=403] RewriteRule .* - [F]
so this:
RewriteRule ^(.*)$ - [R=403,L]
is essentially equivalent to this:
RewriteRule .* - [R=403]
which is the same as this:
RewriteRule .* - [F]
All of which means the initially posted ruleset should have worked
However, when I run the login pages through a header checker I get a series of five 302 re-directs and then it stops/timesout.
actually it means we need more information about how it failed.
I tested the following ruleset with my IP Address correct in the condition:
RewriteCond %{REQUEST_URI} ^/test\.php$
RewriteCond %{REMOTE_ADDR} !^99\.99\.999\.9$
RewriteRule ^(.*)$ - [R=403,L]
> Result: I got in
Then I tested the following ruleset with my IP Address one number off:
RewriteCond %{REQUEST_URI} ^/test\.php$
RewriteCond %{REMOTE_ADDR} !^99\.99\.999\.8$
RewriteRule ^(.*)$ - [R=403,L]
> Result: Forbidden
That really is weird. Now, you're sure your ISP hasn't changed your IP behind your back? :)
Are you in a position to run a RewriteLog? One obvious question, of course, is whether the 403 came from the rule begin tested or some entirely different source.
Do they also remember [F] responses? Did both requests reach the server?
What happens if you change only the target of the rule-- for example, instead of a 403, let it redirect to "foo.html" or some other recognizable name? Then there's no question about whether the rule has executed.
It sure looks as if your server hasn't read the Apache documentation, doesn't it ;)
<IfModule mod_rewrite.c>
RewriteEngine on