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
You can do
window.location = 'http://URL';
to redirect someone in javascriptThis is pretty trivial. You can use
window.location.hostname
to get the hostname of the current page (source). and redirect usingwindow.location.replace
to redirect (source).