限制网站访问特定国家

发布于 2024-12-19 16:34:50 字数 262 浏览 4 评论 0原文


我想知道是否可以使我的网站仅适用于特定国家/地区。 因此,任何试图访问特定国家/地区之外的网站的人都将无法访问。

我正在考虑获取一个 php IP 地理定位器脚本,并在 IP 地址来自我决定的国家/地区时进行重定向。

大家会如何推荐呢?

谢谢。

编辑

这不一定是 100% 准确。只需要 php 代码即可完成我的需要。 顺便说一句,这个国家就是罗马尼亚。谢谢! :)

I am wondering if it's possible to make my website only available to a specific country.
So anyone who tries to visit the website outside the specific country, will not have access.

I was thinking of getting a php IP Geo Locator script and do a redirect if they IP address is from the country I decide.

How would you guys recommend it?

Thank you.

EDIT

This doesn't have to be 100% accurate. Just need the php code that will do what I need.
The country is Romania by the way. Thanks! :)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

沉溺在你眼里的海 2024-12-26 16:34:50

答案取决于“适用于特定国家/地区”的含义。

  1. 如果国内计算机的 IP 地址不在您的列表中怎么办?该计算机无法访问,但它位于国家/地区。

  2. 如果您的列表中有一台国外计算机的 IP 地址怎么办?该计算机将有地址,但它不在所在国家/地区。

  3. 如果具有国内 IP 地址的路由器转发来自国外的请求怎么办?如果国内路由器是 TOR 网络 的一部分怎么办?

  4. 如果公民离开该国家/地区并希望从另一个国家/地区访问您所在国家/地区的网站,该怎么办?该公民将拥有一个不在您列表中的 IP 地址,并且将被拒绝访问。

在您定义“适用于特定国家/地区”之前,您的问题无法得到解答。

The answer depends on what you mean by "available to a specific country".

  1. What if an in-country computer has an IP address not on your list? That computer won't have access, but it's located in country.

  2. What if an out-of-country computer has an IP address on your list? That computer will have address, but it's not located in country.

  3. What if a router with an in-country IP address forwards requests from out-of-country? What if an in-country router is part of the TOR network?

  4. What if a citizen leaves the country and wants to get access to your in-country web site from another country? The citizen will have an IP address not your list and will be denied access.

Until you define "available to a specific country" your question cannot be answered.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文