D
D
Den Belzarayn2019-01-01 09:26:48
htaccess
Den Belzarayn, 2019-01-01 09:26:48

Deny access to users from certain htaccess stans?

How can I block access to users from certain countries using htaccess? And at the same time, do not prohibit search engines from indexing the site.
I used the code, it performs its function, but at the same time the site flies out of the index, as it prohibits access to Google.

SetEnvIf GEOIP_COUNTRY_CODE ^(US|CA|CN) BlockCountry
Deny from env=BlockCountry

Maybe an exclusion rule can be added for search engine bots?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
B
Boris Syomov, 2019-01-01
@kotomyava

It is theoretically possible, but in practice it will be difficult to maintain these rules, even drawing them up will not be easy. There are many search engines, they can come from different ip, addresses can change, and finding everything and updating the list of rules in a timely manner is not at all easy. And focusing on the user-agent is also not reliable.
And in general, banning access for entire countries is a pretty bad idea. Your visitor can go to one of them, for example, even if your target audience is not usually there.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question