On a Drupal website I want to redirect the visitor to a landing page based on the users location. I need this to be more specific than just the users country, but rather I need the province inside the country. When the user does not allow to be located, the user will go to the standard landing page...

Is there an (easy) way to achieve this? I am fairly new to the world of Drupal.


I've had pretty good results previously with SmartIP, and now there is Rules integration which can react to which country the user is in.

So you should be able to set a Rule similar to the following psuedo-rule:


Page is going to be viewed


  • Page is: Front page
  • IP Address is in country: whatever country you want



I know you said you were new to Drupal, so you can find some really useful Rules tutorials at NodeOne: Learn the Rules Framework.


I've just twigged you said you want it to the province level rather than country (sorry, that was glaringly obvious - my fault), so you might be looking at some custom code.

Last time I used it, I used SmartIP to get the latitude and longitude of the user, and then the Location API for the nitty gritty.

You should be able to combine this with hook_init() and drupal_goto() to redirect the user to the relevant page.

| improve this answer | |

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.