Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

128
Vistas
Code is redirecting visitor to homepage no matter what link is clicked

I have a website and would like to redirect visitors from different countries to an URL-Path. For this purpose, I use the code below. The problem with this code is that it always redirects you to the same URL, no matter what link you click on the page. What am I missing?

    <!-- IP REDIRECTING -->
<script>
// Geolocation Redirect
let eng_list = ['BE', 'DK', 'FI', 'FR', 'IS', 'IT', 'HR', 'NL', 'RO', 'SK', 'HU', 'BG', 'GR', 'IE', 'GB', 'CA', 'LU', 'NO', 'PL', 'SE', 'RS', 'CZ', 'TR', 'US', 'AL', 'EE', 'LV', 'LT', 'MK', 'PT', 'SM', 'ES',  'IC', 'EA'];
let presentUrl = location.href;
let targetUrl = "https://www.homepage.de/en";
// Getting the country code from the user's IP
  if (presentUrl != targetUrl) {
$.getJSON('https://ipinfo.io/json', function(data) {
  if (eng_list.includes(data.country)) {
    location.href = "https://www.homepage.de/en";
  }
}, "jsonp");};
</script>
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Your line in the if always redirects to the English "subdomain" as you have it hard coded as such via this line:

location.href = "https://www.homepage.de/en";

Though this not really a "subdomain" but is besides the point. If you want to make it so different languages are actually applied then you need to remove the hardcoding to /en and make that part "vary" based on the conditions needed.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda