0

I'm hoping someone can help me, this HAS to be possible.

My work uses Shopify to run three ecommerce stores for three separate brands. To make things easier for many reasons operationally I have merged the three stores into one.

I need to redirect the existing brand domain names to the appropriate page in the new store. For example www.brandnameone.com.au needs to go to www.shopifystore.com.au/?view=brandnameone

What I'd like to do is detect which domain name the customer is coming from and redirect them.

Is anyone able to help me out with the script beyond

if(document.domain == "brandnameone.com.au")

?

Thanks so much!

mwalker
  • 33
  • 5

2 Answers2

0

You can do window.location = 'http://URL'; to redirect someone in javascript

J Livengood
  • 2,729
  • 1
  • 12
  • 26
0

This is pretty trivial. You can use window.location.hostname to get the hostname of the current page (source). and redirect using window.location.replace to redirect (source).

switch(window.location.hostname){
   case "brandnameone.com.au":
      window.location.replace("www.shopifystore.com.au/?view=brandnameone");
      break;
   ...
}
Derek Brown
  • 4,232
  • 4
  • 27
  • 44