I used .replaceAll to remove the . character because the cloned shopify domain was replacing all occurrences of our domain with their domain before the script was being run in the browser. This causes the site to be stuck in a reloading loop if not using the correct domain.
@David_Sullivan This is an excellent script, but it doesn’t seem to be working for me in regards to the domains that are cloning our website. Here is my script:
*I changed the permanent domain for this post
I added an ‘OR’ operator because we have two live domains right now as we’re getting ready to transition to a new name. I tried it without the ‘OR’ operator and it worked to redirect our second domain, so I know the code works. But when I checked the fraudulent cloned domains, they don’t do anything. The script still shows in the code, but it’s being ignored for some reason.
I’ve not tried this, but just looking at the code the test seems wrong to me. I would think that it should read:
if (window.location.hostname.replaceAll('.','') !== "pnwjourneycom" && window.location.hostname.replaceAll('.','') !== "pnwlifecom") {
As written, I would think that ORing with a non-empty string would make the test always true, which definitely isn’t what is wanted. Also, since the hostname can never be both of the domains, one of the tests will always be true, so the OR would once again always be true. What you’re wanting to check is if it’s not your first domain AND it’s not your second domain, so it should be an AND here instead of an OR.
You’re right, it probably needs an “AND” operator. The script does work after I added in the bracket that was needed. But the “OR” operator sends it into a loop. I decided to just have it all redirect to our new name and get rid of the operator all together.
Looking back at the original code that you posted, I noticed that you changed both occurrences of
"{{ shop.permanent_domain }}"
with
"{{ mystore.myshopify.com }}"
The double brackets cause Liquid to substitute the value of the variable into the output stream. The “shop.permanent_domain” variable contains your shop’s myshopify.com URL, but there is no value in a variable named “mystore.myshopify.com”, so having the double brackets around that causes it to evaluate to an empty string. In that case, it would do the redirect.
You might want to try it again with either the “shop.permanent_domain” value, or without the double brackets and spaces around the “mystore.myshopify.com” and see if that makes a difference for your permanent domain.
Unfortunately, hackers are a perennial problem. It’s hard enough to get rid of them, and everyone who does any kind of activity on the Internet is bound to run into these guys. I’m speaking as someone who has already encountered them sad.
@JustOneGuy Thank you for that. What you’re saying makes sense. I may be misinterpreting the implementation, though, as I tried both options but it still locks up.
Would you be able to modify this (same code as above) to what you are suggesting?
@Investor_life Yes, it’s a super unfortunate thing that there are people in the world who thrive off of taking from others, instead of working and building for themselves. I’m sorry you had to go through it too. I wish there was some way to permanently delete these people. But you’re right, they are a perennial problem and all we can really do is try and protect ourselves from them.
I used a similar firewall with a CloudFlare competitor and it worked at first but my cloner found a way around it and they’re back to cloning my site in real time again. I’ve had this done to me by 6 different domains in less than 3 months.
That’s awesome! Cloudflare is a great service. It’s not something we have the budget for right now as it is not cheap, but will likely use it in the future.