Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

130
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!