Redirect based on subnet

Topics: User Forum
Aug 12, 2010 at 9:34 AM

Hi I am currently trying to setup a list of redirects based on users subnets.  I have about 20 servers and what I am trying to do is when they connect to the main server depending on what subnet they have, they are then redirected to their local server.

So a user with the IP connects to the main server I would like to redirect them to their local server

Then if someone with connects redirect to


Does anyone have an example of how to do this?  Also if possible if their is a query string after the address can you pass that on to the new server?



Aug 13, 2010 at 3:16 AM
Edited Aug 13, 2010 at 3:17 AM

I think what you want is a RewriteCond that references the REMOTE_ADDR HTTP variable. 

You would prepend that to a RewriteRule, I suppose. 

You could map from an incoming IP address to a target server address using a RewriteMap. 


Aug 13, 2010 at 8:36 AM

Hi Cheeso,

Thanks for the reply, however is there any chance that you could provide an example?


Aug 13, 2010 at 6:06 PM
Check the documentation on the RewriteCond directive. There are numerous examples shown there. My impression is that You need to get more familiar with how iirf works before you attempt to solve your problem. Spend some time with the user's manual, run some tests, and I'm sure you'll quickly gain insight. Good luck.