I want to redirect all the inside network IPs (and only the inside network "192.168.1.0") to an error page except some IPs, A condition like this:
if ( IP_from_Network = 192.168.1.0 and ((IP != 192.168.1.4) or (IP != 192.168.1.5)
or (IP != 192.168.1.6)) )
{
redirect to an error page
}
so I have trying to achieve this using RewriteEngine:
RewiteEngine On
RewriteCond %{REMOTE_ADDR} !^192\.168\.1\.4$ [NC]
RewriteCond %{REMOTE_ADDR} !^192\.168\.1\.5$ [NC]
RewriteCond %{REMOTE_ADDR} !^192\.168\.1\.6$ [NC]
RewriteCond %{REMOTE_ADDR} ^192\.168\.1\.*$ [NC]
RewriteCond %{REQUEST_URI} ^/test/manager/.* [NC]
RewriteRule ^(.*)$ - [R=404,L]
but this didn't work for me
Should I use other tags like [OR] or [AND]?
Update:
Directory tag:
<Directory /var/www/html/test>
Order allow,deny
Allow from 192.168.1
RewriteEngine on
RewriteCond %{REMOTE_ADDR} !^192\.168\.1\.4$ [NC]
RewriteCond %{REMOTE_ADDR} !^192\.168\.1\.5$ [NC]
RewriteCond %{REMOTE_ADDR} !^192\.168\.1\.6$ [NC]
RewriteCond %{REMOTE_ADDR} ^192\.168\.1\.*$ [NC]
RewriteCond %{REQUEST_URI} ^/test/manager/.* [NC]
RewriteRule ^(.*)$ - [R=404,L]
</Directory>
allow from 192.168.1because I want every body to reach test directory but in the case of manager directory I want forbid all IPs exept some see question updates.^192\.168\.1\.*$. Is that intentional? I would expect that to match REMOTE_ADDR values like192.168.1,192.168.1.and192.168.1......., not192.168.1.123. Have you tried^192\.168\.1\..*$? (Not perfect, but likely better.) Not too familiar with mod_rewrite and not sure this is your problem so not a full answer yet. Ping me with whether that works and if it does I'll type up a fuller answer.