How do I limit which countries can view my website ( PHP )

后端 未结 6 2096
盖世英雄少女心
盖世英雄少女心 2020-12-30 07:44

In there an easy way to do this in PHP. I want to make sure that only web requests from certain countries are able to access my website.

Any ideas?

6条回答
  •  别那么骄傲
    2020-12-30 08:27

    if you use the answer of Ben Dowling and the code doesn't work, try this:

    if (!in_array(substr($country, 0, 2), $allowed_countries)) {
    

    instead of:

    if(!in_array($country, $allowed_countries)) {
    

提交回复
热议问题