skip to Main Content

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!

2

Answers


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

    Login or Signup to reply.
  2. 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;
       ...
    }
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search