The customer portal my.neoserv.com has been redesigned. If you notice any issues, please let us know.

Cart (0)
  • Your cart is currently empty.

NEOSERV BLOG

Tips, guides and useful information about domains, hosting, SSL certificates, email, web optimization and online security.

Preusmeritev obiskovalcev spletne strani
Category: Websites
Published:

Do you have several websites in different languages, each on its own domain? Do you want visitors to be automatically redirected to a specific website? This scenario is particularly common in the case of an online shop, where not only the language difference is necessary, but also the offer itself can be tailored to the specific market.

Let’s assume you have three domains registered:

  • moja-domena.si,
  • moja-domena.eu,
  • moja-domena.com.

Each of them has a website, but in different languages – .SI in Slovenian, .EU in German and .COM in English. The first website is aimed at visitors from Slovenia, the second is aimed at the German-speaking population, and the third is aimed at all other web users.

Your aim is therefore to show visitors the right website for their country of origin. In this case, you can help yourself with a command that you enter in the .htaccess file.

The .htaccess file is located in the Root Directory of the domain or subdomain. Because it is a hidden file, you must have the cPanel control panel or FTP client enabled to show hidden files. If you don’t already have a .htaccess file, you will need to create one first.

For the example described here, we would add the following to the very top of the .htaccess file:

<IfModule mod_maxminddb.c>

MaxMindDBEnable On

# Redirect Slovenian IP addresses to .SI domain

RewriteCond %{HTTP_HOST} (.*)?moja-domena\.(com|eu) [NC]
RewriteCond %{ENV:GEOIP_COUNTRY_CODE} ^SI$
RewriteRule ^(.*)$ https://www.moja-domena.si/$1 [R,L]

# Redirect German and Austrian IP addresses to .EU domain

RewriteCond %{HTTP_HOST} (.*)?moja-domena\.(si|com) [NC]
RewriteCond %{ENV:GEOIP_COUNTRY_CODE} ^(DE|AT)$
RewriteRule ^(.*)$ https://www.moja-domena.eu/$1 [R,L]

# Redirect other IP addresses to .COM domain

RewriteCond %{HTTP_HOST} (.*)?moja-domena\.(si|eu) [NC]
RewriteRule ^(.*)$ https://www.moja-domena.com/$1 [R,L]

</IfModule>

Let’s briefly explain the above .htaccess code:

  • If a web user from Slovenia wanted to visit a .COM or .EU domain, they would be automatically redirected to the .SI domain.
  • If a user with a German or Austrian IP address tried to visit a website on .SI or .COM, they would be redirected to .EU.
  • All other web users would be redirected from .SI and .EU to .COM.

A table of the two-letter country codes can be found here.

COMMENTS

COMMENT THE POST

(mandatory)
(mandatory, email address will be hidden)
(optional)
Security question that confirms you are a real person.