0

I'm looking for advice on how to redirect a user to one of our country sites, based on their IP and wondered if anyone has done this with ExpressionEngine?

Additionally, I need to provide users with a way to circumvent this - similar to what happens with Google where you can click a link that can take you to the .com site if you don't wish to view the .co.uk site.

I have IP to Nation installed and updated, but unsure if this would be needed.

Thanks.

1
  • From a UX perspective, I think is really annoying to be redirect without my consent. I suggest you to show a message and a link the site of the user's country. Otherwise, you gonna need to use cookies and JS to deal with the users who want to visit the foreign site. – Robson Sobral May 11 '13 at 18:50
1

Because of parse order, the ip_to_nation module just works on channel:entries or comments. The necessary {ip_address} variable is a global variable, which means it is parsed after the variables of ip_to_nation.

You should use IPGeo add-on to get the visitor's location info based on IP address like:

{exp:ipgeo}

{if country == 'India'}

{exp:redirecturl url="http://examplesite.in"}

{/if}

{/exp:ipgeo}

You can see for the redirect, I used plugin http://devot-ee.com/add-ons/redirecturl-ee2-plugin as standard global variable {redirect} wouldn't work here.

2
  • @doubleplusgood: if my answer is fit for your question, can you please mark it as solution. – Bhashkar Yadav Apr 11 '13 at 16:51
  • Will do. It's part why there as I still need a way to circumvent this so if a user does actually want to visit the UK site, but the above will help in the short term. – doubleplusgood Apr 11 '13 at 18:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.