httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Saqib.N....@seagate.com
Subject Re: [users@httpd] redirection based on client IP address (only first two octets) / External Rewriting Engine
Date Mon, 18 Nov 2002 18:02:44 GMT

Thanks Joshua, I will try this Rule.

However I have come to realize our problem is more complex, and can not be
solved via simple rewrite rules. I think I will need to use External
Rewrite Rule to perform the redirection task.
http://httpd.apache.org/docs-2.0/misc/rewriteguide.html mentions a perl
script can be written to act as the Rewrite Map. Can anyone give me
examples of such a script. How to pass in the input and what output is
expected.

Thanks
Saqib Ali



                                                                                         
                               
                    Joshua Slive                                                         
                               
                    <joshua@slive        To:     users@httpd.apache.org               
                                  
                    .ca>                 cc:                                          
                                  
                    No Phone Info        Subject:     Re: [users@httpd] redirection based
on client IP address (only     
                    Available            first two octets)                               
                               
                                                                                         
                               
                    11/18/2002                                                           
                               
                    09:37 AM                                                             
                               
                    Please                                                               
                               
                    respond to                                                           
                               
                    users                                                                
                               
                                                                                         
                               
                                                                                         
                               




On Mon, 18 Nov 2002 Saqib.N.Ali@seagate.com wrote:

> Hi All,
> I have the following REWRITE rules to redirect based upon client IP
> address. The redirection works fine. However now I want to redirect based
> on only first 2 octets of the IP address. e.g:

Something like this (untested, but it should give you the idea):

RewriteMap  redirector txt:/tmp/redirector.map
RewriteCond %{REMOTE_ADDR} ^([0-9]*\.[0-9]*)\..*$
RewriteCond ${redirector:%1|NO-REDIRECT} (http://.*)
RewriteRule ^.* %1 [R,L]

Note that %1 is a back-reference to the matched portion of the last
RewriteCond.

I've also improved your rules a little by making only one lookup in the
map.  Note that the second RewriteCond will fail when the map-lookup
fails,  because NO-REDIRECT doesn't match http://.*.  Then the RewriteRule
simply uses the results of that lookup for the redirect.

Joshua.



---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org





---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Mime
View raw message