Author Topic: Redirect based on IP  (Read 977 times)

Offline r4lphuk

  • Contributor
  • *
  • Posts: 6
  • Karma: 0
Redirect based on IP
« on: January 09, 2012, 02:42:53 PM »
Guys,

I'm looking for a way to redirect based on a client IP to a specific site URL, I've imported a location database onto the Netscaler and that works - however I cant seem to get my policy right, the redirect goes into an endless loop.  For example

1. FR user visits www.example.com
2. IP address lookup shows user is from FR and is sent to www.example.com?currency=EUR

I'm utilising a responder policy to check for the IP and a responder action to perform the redirect however it goes into an endless loop, can any advise? I initially thought of placing a cookie into the HTTP response but this never makes it as the responder policy is evaluated before a re-write.

Any help is much appreciated.

Thanks.

Offline mkalle

  • VIP Member
  • ***
  • Posts: 25
  • Karma: 1
Re: Redirect based on IP
« Reply #1 on: January 10, 2012, 12:37:55 AM »
make you responder policy something like

CLIENT.IP.SRC.MATCHES_LOCATION(\"Europe.FR\") && HTTP.REQ.URL.CONTAINS("currency=EUR").NOT

.NOT is quite importent else you will get the endless loop.

Offline r4lphuk

  • Contributor
  • *
  • Posts: 6
  • Karma: 0
Re: Redirect based on IP
« Reply #2 on: January 10, 2012, 01:12:33 AM »
mkalle , thanks for the pointers... could oyu break down the statement, what is the .NOT doing?

Offline mkalle

  • VIP Member
  • ***
  • Posts: 25
  • Karma: 1
Re: Redirect based on IP
« Reply #3 on: January 10, 2012, 05:16:55 AM »
Then the rule wont work when you request something like www.example.com?currency=EUR

And you proberly only want it to work on the front page right?

then something like
CLIENT.IP.SRC.MATCHES_LOCATION(\"Europe.FR\") && HTTP.REQ.URL.EQ("/") is really a good idea, else it will triggered on all other requests.

You should really read the "Traffic Management Guide" for the netscaler.

Offline r4lphuk

  • Contributor
  • *
  • Posts: 6
  • Karma: 0
Re: Redirect based on IP
« Reply #4 on: January 10, 2012, 05:41:56 AM »
Correct, yes we only need it for the landing page (home page), once currency is selected our application drops a cookie to preserve the choice.

Your recent example works perfectly, thanks for all your help.  I will get my head into the "Traffic Management Guide" - I think I need to fully understand the "boolean" operators.

Cheers,