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
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.
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:
.com → .co.uk
.com/… → .com/uk/…
Easily…
[ifso-redirect url='{{SCHEME}}://{{DOMAIN}}.{{TLD}}{{PATH}}']
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:
Parameter | Example |
{{SCHEME}} | https |
{{HOST}} | if-so.com |
{{PATH}} | /subdir/something/index.php |
{{QUERY}} | hello=world |
{{DOMAIN}} | if-so |
{{TLD}} | com |
Applying the shortcode on multiple pages is possible in two ways:
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}}']"); ?>
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.