DEAL ENDS IN:

CHIRSTMAS SALE!

UP TO 40% OFF!

GET IT NOW

Geolocation

Geolocation Redirect Templates

Automatically redirect users from any page on your site to an equivalent page on a parallel website!

Commonly used for: Redirecting every page on a .com website to an equivalent page on a co.uk website.

On this page

  • What is the ‘Geolocation Redirect Template’?
  • Common use cases
  • How to set it up (1 min)

What is the ‘Geolocation Redirect Template’?

The ‘Geolocation Redirect Template’ option enables you to effortlessly redirect visitors to parallel pages on another website using a single, straightforward shortcode.

The redirection URL is automatically generated for each page using one single shortcode.

All the features available in our standard redirection shortcode, including the ability to redirect users only once and choose the redirection type (301/302/JavaScript), are also applicable with the Geolocation Redirect Template.

Common use cases

The shortcode is structured in a way that allows you complete flexibility to construct any URL template you want.

The most common use cases, however, are:

  • Redirecting users from a .com/pageX to a .co.uk/pageX
  • Redirecting users from a .com/pageX to .com/uk/pageX

.com .co.uk

Geolocation Redirect Template

.com/… .com/uk/…

Geolocation Redirect Template permalink

How to set up the Dynamic Geolocation Redirect Template Shortcode?

Easily…

  1. Paste the following shortcode on your page
 [ifso-redirect url='{{SCHEME}}://{{DOMAIN}}.{{TLD}}{{PATH}}']
  1. Replace the relevant URL parameters with static values according to your needs.

The parameters will grab their value automatically from the page the shortcode is applying to. If you want to redirect users from a .com site to a parallel page on a .co.uk site, for example, all you need to do is replace the {{TLD}} parameter with the value co.uk, and keep the rest of the parameters as is.

For example:

 [ifso-redirect url='{{SCHEME}}://{{DOMAIN}}.co.uk{{PATH}}']


The table below lists the available parameters and their values:

ParameterExample
{{SCHEME}}https
{{HOST}}if-so.com
{{PATH}}/subdir/something/index.php
{{QUERY}}hello=world
{{DOMAIN}}if-so
{{TLD}}com

Applying the geolocation redirection template shortcode on all of your website’s pages simultaneously?

Applying the shortcode on multiple pages is possible in two ways:

  1. Using If-So’s “Apply shortcode on all pages” option. Learn more.
  2. Embedding the shortcode directly on your template files using PHP.

To include the shortcode on all your product pages at once using PHP, simply use the following code:

<?php echo do_shortcode("[ifso-redirect url='{{SCHEME}}://{{DOMAIN}}.co.uk{{PATH}}']"); ?>

FAQ: How can I prevent an endless redirection loop when using the Dynamic Geolocation Redirect Template Shortcode on all pages?

In some cases, applying a dynamic geolocation redirect across all pages of your website can cause an endless redirection loop.

For example, if you want to redirect all visitors from France to a URL that includes the /fr/ subfolder (i.e., domain.com/pageX > domain.com/fr/pageX), and you embed the shortcode on all of your website’s pages through one of the suggested methods, the redirection will apply endlessly—since it will also trigger on the page domain.com/fr/pageX.

To prevent this, you need to add another version to your trigger so that if the page URL contains /fr/, the redirection won’t be applied.

Steps to prevent endless redirection:
1. In your trigger, click “Add a new version.”
2. Set the version’s condition to: Page URL > Contains > /fr/
3. Leave the version content field blank.
4. Drag the new version to the top (making it version A). This ensures the condition for this version is checked first and applied if the condition is met.

The result: If the page URL contains /fr/, version A will be displayed, preventing the redirection from happening again.

Related content

Ready to get started?
Try it on your website