window.location.replace(newurl.com) does not replace currenturl.com with newurl.com, but adds to newurl.com to currenturl.com. So it becomes currenurl.com/newurl.com

Read more here: window.location.replace() does not replace, but adds to url


Solution:

If you know the solution of this issue, please leave us a reply in Comment section, to update the question.


Wordpress related questions and answers: