Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to redirect pages in old website to same path in multiple websites randomly

I have a code to redirect page in old website to same path in new website
but I need to redirect page to same path for multiple websites randomly
website1.com , website2.com and website3.com

window.location.href = "http://" + "website1.com/" + window.location.pathname

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Like this, if you insist on doing on the client

const sites = ["site1.com","site2.com","site3.com"];
let site = sites[Math.floor(Math.random()*sites.length)];
let url = `https://${site}${window.location.pathname}`;
console.log(url)
//window.location.href = url;
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading