At Kinsta, it’s possible to use IP Geolocation to tailor the content shown on your website to visitors in different areas of the world.

IP Geolocation functionality is built right into your MyKinsta dashboard. You can direct traffic based on location, giving you flexibility and granting your visitors a customized experience.

What Is IP Geolocation?

IP Geolocation, or internet geolocation, is a form of geolocation used to determine a computer’s physical location by identifying its IP address.

Thanks to information gathered through IP Geolocation, you’re able to set up rules that automatically send visitors to different subdomains or pages of your site based on their physical location. This introduces infinite flexibility to your site, and it lets you decide exactly what each user should see, all based on where they are.

What’s more, by pairing the power of IP Geolocation with that of an edge-based cache system like Cloudflare, you can noticeably decrease your time to first byte (TTFB) by automatically sending users through caches situated near their own physical locations.

You should be aware that IP Geolocation is not as accurate as other methods of geolocation such as GPS. In fact, users could thwart IP Geolocation targeting attempts by disabling geolocation in their browser or through the use of an IP-cloaking service like a virtual private network (VPN).

Having said that, IP Geolocation is certainly an invaluable tool for serving your visitors, as catered, personalized experiences have become vital to engagement and conversion.

Common Uses of IP Geolocation

The three most common implementations of IP Geolocation include:

  • Redirection based on the visitor’s detected location
  • Page cache differentiation based on the visitor’s detected location
  • Blocking traffic from specific geographic locations

Let’s take a look at these use cases more closely.

Location-Based Redirection

Let’s say you have a website at example.com. Imagine that you build a new page specifically targeting visitors from the UK and you wish to have all visitors from the UK redirected to example.com/uk/. This can be accomplished easily with the MyKinsta Geolocation tool.

It’s possible to expand this arrangement as needed too. For instance, you could set up the following arrangement for visitors from different locales:

  • Rule 1: Visitors from the UK redirected to example.com/uk/
  • Rule 2: Visitors from the United States (US) and Canada redirected to example.com/us/
  • Rule 3: Visitors from Mexico redirected to example.com/mx/
  • Rule 4: Visitors from India redirected to example.com/in/
  • Rule 5: Visitors from Australia redirected to example.com/aus/
  • No rule triggered: All other visitors to remain at example.com

Location-Based Cache Differentiation

Some plugins and themes include features that detect the visitor’s location and customize content, such as language or currency, based on the visitor’s location. IP Geolocation can be harnessed to build separate caches for each country, displaying custom content and improving load times for visitors from that area.

Let’s consider an example. Imagine that your website, example.com, displays pricing in euros (€), British pounds (£), and US dollars ($).

You set up a plugin to automatically switch between these three currencies based on the visitor’s detected location. Then, you would use IP Geolocation rules to build three separate cache buckets to make it possible to display the right currency based on location, while simultaneously continuing to use our server caching to keep the site fast and scalable.

  • Rule 1: Cache visitors from the US in cache bucket 1. Website configured by the user to display US dollars.
  • Rule 2: Cache visitors from the UK in cache bucket 2. Website configured by the user to display British pounds.
  • No rule triggered: Cache bucket 3 if for all other visitors. Website configured by the user to display Euros for all other visitors.

With this IP Geolocation setup, you can enjoy the added benefit of automated sales tax calculation for every shopper based on their location.

The less work your customers have to do when buying from you, the better. This includes saving them the effort of accurately calculating their purchase totals on their own.

Location-Based Traffic Denial (Geo-Blocking)

Blocking site traffic based on geography, also known as geo-blocking, is the simplest use case to understand.

Imagine you’re running a business that can only sell to visitors from a specific country. With a simple redirect rule in MyKinsta, you can easily restrict access to the site only to visitors from a single country.

You can either deliver a simple “403 Forbidden” message to all other visitors or redirect them to a landing page of your choosing.

Info

Enabling Geo-blocking through MyKinsta isn’t currently available as a built-in feature. If you need it, feel free to reach out to our support team with detailed information and they will implement the redirect rule for you.

Combining IP Geolocation Functionality

It is also possible to combine multiple types of IP Geolocation-based rules to implement a more granular control. For example, the following configuration could be accommodated:

  • Rule 1: Visitors from the USA redirected to example.com/us/
  • Rules 2, 3, and 4: Separate cache buckets created for visitors from the USA, Canada, and Europe
  • Rule 5: Visitors from another country where the advertised service is not available blocked entirely

IP Geolocation and WordPress

WordPress has long offered plugins that can facilitate IP Geolocation functionality. Some, like IP Geolocation Country Redirect or GeoTargetingWP, focus on helping you guide traffic around your site based on visitors’ locations. Others offer a broader spread of IP Geolocation features aimed at boosting marketing efforts, such as the CF Geo Plugin.

So why build this functionality into MyKinsta? Why not simply let customers use a plugin for their IP Geolocation needs?

Well, for one, plugins need to be maintained. To be sure your site continues working smoothly, you’ll have to watch for updates to the plugin and fully understand the release notes before updating to each new version. And there’s always the risk of an update breaking some aspect of your site.

Additionally, plugins can introduce inherent security risks to your site. Because plugins are maintained by third-party authors, it’s possible that malicious scripts could be introduced through a plugin to your site, wiping out your web presence and even your stored data.

Although plugins can bring some amazing functionality to your site, we generally advise keeping your total plugins to a minimum. Only install plugins from authors you trust, with established histories of frequent, well-documented updates.

As you can imagine, it’s better to have a trusted source handle your IP Geolocation preferences. By having IP Geolocation functionality built right into MyKinsta, you’re able to set your geolocation requirements right on your instance’s server, where it will be protected from client-side security risks.

IP Geolocation and Nginx

All sites hosted at Kinsta run on Nginx servers. Nginx is an open-source web server that’s known for its manifold capabilities that include a reverse proxy, load balancer, and HTTP cache, in addition to its speed.

One of the benefits Nginx servers offer is the use of precompiled MaxMind GeoIP2 databases for our GeoIP module. The module handles both HTTP and TCP/UDP traffic, allowing you to create flexible rules based on your visitors’ IP addresses.

MaxMind’s GeoIP2 databases are updated constantly, and all requests are scanned for fraudulent activity or sensitive data (e.g. GDPR-related requests from EU-based visitors).

You can read more about Nginx’s GeoIP module in their official documentation.

How to Set up IP Geolocation in MyKinsta

Kinsta customers are able to add IP Geolocation to their sites through their MyKinsta dashboard. The process is quick, simple, and highly customizable.

Important

Before enabling the Geolocation tool, be aware that incorrect use of redirect rules might bring unexpected results, impacting your SEO and the user experience of your site. We provided best practices on how to implement IP Geolocation below.

Enabling the Geolocation Tool

To get started, log in to your MyKinsta dashboard and navigate to the Sites view. From there, click on the site for which you want to enable IP Geolocation:

The Sites section of MyKinsta.

The Sites section of MyKinsta.

Once you’re at your site’s dashboard, click on Tools at the left. Find Geolocation in the list of tools and click Enable:

Geolocation can be enabled from the Tools section of MyKinsta.

Geolocation can be enabled from the Tools section of MyKinsta.

You’ll be shown a modal with three options:

  1. Disabled: This is the default setting for sites.
  2. Enabled for country level: Enable IP Geolocation at the country level.
  3. Enabled for country and city: Enable IP Geolocation at both the country and city level.

Options two and three allow you to enable Kinsta’s geolocation feature for your site. Select the option you prefer, then choose Modify:

MyKinsta geolocation modal for choosing country level or country and city.

MyKinsta geolocation modal for choosing country level or country and city.

After a few moments, you’ll be returned to the Tools dashboard and shown a success message:

MyKinsta geolocation toggle confirmation message. This is your confirmation that IP Geolocation is now enabled for your site.

MyKinsta geolocation toggle confirmation message.

And that’s it! IP Geolocation has now been enabled for your Kinsta-hosted site, and you’re clear to move forward with specifying which visitors see which pages.

How to Add IP Geolocation Rules and Redirects in MyKinsta

Once you’ve enabled IP Geolocation for your site, you’ll have the option to control your inbound traffic through the addition of redirect rules in MyKinsta.

From your MyKinsta dashboard, navigate to the site you want to add rules to, then choose Redirects from that site’s menu and select Add redirect rule:

The Add redirect rule button from the Redirects section of MyKinsta.

The Add redirect rule button from the Redirects section of MyKinsta.

A modal titled “Add redirect rule” will appear. This is where you’ll define your redirect’s parameters:

MyKinsta redirect modal showing "Traffic from" fields for geolocation redirect rules.

MyKinsta redirect modal showing “Traffic from” fields for geolocation redirect rules.

Here, you’ll fill out all the fields to redirect your traffic:

  1. Domain: Pick the domain for which you’re adding the redirect. To add the redirect to all domains within this site, leave this with the default option (“All domains”).
  2. Redirected from: Enter the page or directory you want traffic redirected from. You can use regex in this field.
  3. Redirected to: Enter the page or directory to which you want traffic rerouted.
  4. Traffic from: Choose the country (and city, if you enabled country/city-level IP Geolocation) of the traffic you want to redirect.
  5. HTTP status code: Decide whether the redirect will be temporary (302) or permanent (301). You can find more details in the “Best Practices for Implementing IP Geolocation” section below.
The "Add redirect rule" button will enable your redirection rule via MyKinsta.

The “Add redirect rule” button will enable your redirection rule via MyKinsta.

Once you’re done filling out the modal, click Add redirect rule at the bottom.

Struggling with downtime and WordPress problems? Kinsta is the hosting solution designed to save you time! Check out our features

And voilà: you’re now taking full advantage of IP Geolocation and successfully redirecting traffic coming from that location to a specific area of your site!

You can edit any rules you’ve created in the past from this Redirects page as well.

Check out our knowledge base article on adding and managing redirects for more information about redirecting traffic by location through MyKinsta.

Best Practices for Implementing IP Geolocation

Incorrect use of redirect rules can produce unexpected results, impacting your SEO and user experience. To avoid this, we recommend adhering to the following best practices for redirect rule instatement.

1. Start on Staging

Implement your redirect rules on your staging server before touching your live server settings. This will give you an opportunity to spot redirect issues before they become your users’ problem.

2. Look for Plugin Conflicts

Some WordPress plugins may automatically set cookies with their own redirects, so you could encounter conflicts when pairing these plugins with the MyKinsta Geolocation feature.

Test your plugins and their settings on staging before pushing your redirects live to your production site.

3. Use 302 for Location Redirects

Google recommends utilizing 302 redirects (rather than 301) for location-based redirects or relocations on your site. See our list of 300 redirect status codes for more details.

4. Test From Various Locations

Check your location-based rules by accessing your site from another geographic location using a VPN or proxy service. This will let you experience your site (including your redirects) as your international users would.

5. Avoid Blocking Search Bots

Search engines generally crawl from the country in which they’re based. According to Deepcrawl, Google and Bing‘s search bots crawl from the US, while Baidu crawls from China and Yandex from Russia.

Blocking these search engines with a faulty location-based redirect can have a negative impact on your SEO. Once you’ve decided which search engines you want accessing your site, carefully double-check your redirect rules to ensure you’re not blocking them.

Suppose, for example, you were to add a redirect funneling US-based users visiting your non-English pages to their English pages. This could mean that Google and Bing’s bots are also redirected, preventing them from being able to crawl and index your non-English pages and resulting in those pages being excluded from search results.

Note that redirects on a city level will not impact these bots — only country-level redirects. If you’re not sure which country a search engine hails from, you can perform a reverse DNS lookup to check the origin and authenticity of a crawler.

It’s also worth noting that most search engines have a zero cloaking policy, so it’s important to avoid making special rules for search bots (i.e. redirecting users but not bots).

6. Make Your Redirects Visible

Just as important as not blocking search bots is making your redirects visible to them. There are a few ways to do this:

  • Generate an XML sitemap to highlight all the pages you want indexed for each language version. This sitemap should be submitted to Google Search Console, Bing Webmaster Tools, and any other search engine you wish to target. You can then use the tools provided by each search engine to review crawling and indexing issues with your site.
  • Use the Inspect URL tool in Google Search Console to check if individual pages are eligible to be crawled and indexed.
  • Use the site search Google search operator to check whether your pages have been indexed. You can do this by affixing “site:” to your domain or subdomain in your search (e.g. site:example.com/pt/ would return all indexed URLs with this path).
  • Implement hreflang attributes to highlight all language versions of your pages. You can utilize the International Targeting report in Google Search Console to monitor any issues with your hreflang setup.
  • Create Google Search Console properties for each country path and use the Country Targeting tool to set specific countries to target (not recommended if you target multiple countries with the same language).

7. Don’t Rely on Cookies

While cookies can be useful to your visitors, it’s important to remember that not everyone uses them. Some visitors may even be utilizing a VPN for work or personal reasons, which can negate native cookies and interfere with your location detection efforts.

What’s more, cookies are sometimes ignored by search bots, dampening your SEO efforts. For these reasons, we recommend avoiding relying on cookies for redirects.

Additionally, Googlebot and Bingbot don’t save cookies, so keep this in mind if you do plan to use cookies as part of your solution.

Summary

Setting up IP Geolocation for your sites is a breeze with MyKinsta. Specifically, you can enable the IP Geolocation feature at the country or country/city level with just a few clicks. Then, you can set up location-based redirects that best suit your needs.

If you have any questions, our support team is here for you 24/7.


If you enjoyed this tutorial, then you’ll love our support. All Kinsta’s hosting plans include 24/7 support from our veteran WordPress developers and engineers. Chat with the same team that backs our Fortune 500 clients. Check out our plans