Silly question I’m sure, but do countries generally get an IP range that can be banned? Say for example China (nothing against China), has a IP that always starts with 40.xxx.xxx.xxx, I’d like to block them via the htaccess file (unless there’s a better way) with wild cards, like 40...* if that’s even possible?
There are geoIP lists you can get, like the one from maxmind. The More accurate (more frequently updated) ones are paid but there are free lists. I’m not sure if you can do it with htaccess but using a firewall might be a better option anyway. There are no rules that link an IP address range to a country. The lists work by finding out which IP blocks belong to which ISPs and what the location of those ISPs are, this changes all the time hence the need for the lists to be kept up to date.
Thank you for that Dexter, really kind of you. I’ll have a look at maxmind, I was fumbling with someones website the other day and found a link to this dating looking, but perhaps informative website. I wonder if that’s a good start - like everyone, I don’t want to pay.
You said about using a Firewall, I’m going to look into that to see if my hosting offers that.
Really helpful to know that countries aren’t assigned a specific IP address, kind of a shame, but I say that with no experience of connecting countries!
Thank you for that, I checked briefly with my hosting and they don’t have a firewall function. I expect that for little one man businesses, it’s probably not worth it. Oh well!
It might seem over kill but I only ask for an on-site service web site, like pool cleaners, gutter repair, etc. I thought it might cut down on form spamming and unnecessary usage. I know some might VPN but if they’re prepared to do that, they’re welcome!
You can use a combination of alternate/hreflang and canonical to instruct search engines (e.g. Google, Yandex) to treat one of your pages as the default, and another to be indexed and presented to users with specific languages in specific regions.
Put lightweight/static/form-less content on the undesirable language page(s) and that should help a bit. Just make sure you don’t link back to the canonical page from those.
This approach works by “tainting” the search engine results such that spammers can’t ‘find’ your real site in the first place. It can be circumvented by simply changing the language/region settings on your browser/operating system. If your web logs show that the spammers aren’t bothering to do that, however, then it could prove effective.
Note: The example above is a blacklist approach — directing everyone towards your legitimate/fully-functional page except for a specific set of exceptions. You can flip it around and adopt a whitelist approach — misdirecting everyone by default and only directing a subset towards the legitimate page:
Put it behind Cloudflare free, protects you from all sorts of attacks, ddos, and handles geoblocking as well. Hides your IP as well, which is really helpul for security, and works as a free CDN to cut down your transfers/bandwidth costs. It’s an amazing free service that anyone hosting a website with their own domain should use.
That’s brilliant L1, thank you very much, I really do appreciate your full explanation and code, massively kind of you. I’ll definitely do that as it actually makes sense to me! Very kind indeed though, thank you
Thank you for that @Ruffalo , I had heard Cloudflare but never really knew what it did. I’ll definitely look into it, very much appreciated. Oh, it won’t affect SEO will it?