Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

129
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda