Restrict URL's starting with /abc to specific IP's [.htaccess guru]

Permalink
I'm trying to protect URL's, starting with a specific slug (let's say /abc), by allowing specific IP's only. Let us assume my IP address is 123.123.123.123. I have the following htaccess code, which does the exact opposite (only allowing /abc and blocking the rest):

RewriteCond %{REQUEST_URI} !^/abc
RewriteCond %{REMOTE_ADDR} !^123\.123\.123\.123
RewriteRule ^(.*)$ - [R=403,L]


Now, does anyone know how to turn that around? So allow everything, EXCEPT the URL's starting with /abc? I tried removing the exclamation mark and several other things, with no success. The code above works though, but that's not what I want to achieve unfortunately.

ramonleenders
 
jero replied on at Permalink Reply
jero
Try this:

RewriteEngine On
RewriteCond %{REQUEST_URI} ^/abc
RewriteCond %{REMOTE_ADDR} !=10.0.0.1
RewriteCond %{REMOTE_ADDR} !=10.0.0.2
RewriteCond %{REMOTE_ADDR} !=10.0.0.3
RewriteRule . http://www.bbc.co.uk [R=301,L]


if the url begins with /abc and the remote address is not one of the three listed, send the browser on its merry way.