httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Walter H." <Walte...@mathemainzel.info>
Subject Re: [users@httpd] RewriteEngine conditions?
Date Thu, 07 Aug 2014 19:20:48 GMT
On 07.08.2014 15:48, Igor Cicimov wrote:
>
>
> On 07/08/2014 2:47 PM, "Mark jensen" <ngiw2012@hotmail.com 
> <mailto:ngiw2012@hotmail.com>> wrote:
> >
> > I want to redirect all the inside network IPs 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' 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]
> >
> > Is this would do what I want or should I use other tags like [OR]?
> Can't you just use:
>       RewriteCond   %{REMOTE_ADDR}   ^192\.168\.1\.*$
>       RewriteCond   %{REMOTE_ADDR}   !^192\.168\.1\.4$
>       RewriteCond   %{REMOTE_ADDR}   !^192\.168\.1\.5$
>       RewriteCond   %{REMOTE_ADDR}   !^192\.168\.1\.6$
> No need to complicate.
>
the first RewriteCond seems to be syntactically not what you want
try this:

RewriteCond   %{REMOTE_ADDR}   ^192\.168\.1\.[0-9]+$

or just simplier this:

RewriteCond   %{REMOTE_ADDR}   ^192\.168\.1\.

Walter

Mime
View raw message