【问题标题】:How to Restrict Specific Ip Addresses to Xampp如何将特定 IP 地址限制为 Xampp
【发布时间】:2021-08-21 03:21:33
【问题描述】:

在我的场景中,我已经成功安装了 xampp。我有一些小型网站和网络应用程序。我想限制一些网络 ip 只访问网站。我尝试了很多方法,例如

Order allow,deny
deny from all 
allow from 192.168.1.107

也用</Directory /xampp/htdocs/webapp> 做到了。但它没有用。

当我做这件事的时候。甚至我的电脑 192.168.1.107 也无法访问该网站。这是发生的实际问题。

在我的情况下,我的静态 ip 从我的路由器保留,我想将其限制为仅我的 ip 或提供给 httpd.conf 文件的 ip。

【问题讨论】:

  • 将.htaccess放在根目录下。

标签: php apache xampp httpd.conf


【解决方案1】:

使用 htaccess 并仅允许访问您的 IP 地址

# Remove the php extension from the filename
# Disable directory browsing 
Options -Indexes
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]
# Set the headers for the restful api
Header always set Access-Control-Allow-Origin 192.168.1.107
Header always set Access-Control-Max-Age "1000"
Header always set Access-Control-Allow-Headers "X-Requested-With, Content-Type, Origin, Authorization, Accept, Client-Security-Token, Accept-Encoding"
Header always set Access-Control-Allow-Methods "GET"
#Deny from %{REQUEST_FILENAME}

更新

Header always set Access-Control-Allow-Methods "GET"

可以包含 GET、PUT、DELETE、POST

Header always set Access-Control-Allow-Methods "GET,PUT,DELETE,POST"

取决于你想要达到的目标

【讨论】:

  • 1.我想知道的是 .htaccess 文件应该在我想通过 IP 地址限制的 webapp 文件夹中吗? 2.我可以添加多个IP地址吗? 3. 我的场景很简单。我对 GET PUT DELETE POST 了解不多
  • .htaccess 应该在你的项目根目录@TheMangoMan
  • 我试图把它放在 htdocs 文件夹之后,我无法访问它说权限被拒绝的网络服务器。
  • @TheMangoMan 将其添加到项目的根目录中。不在您的 htdocs 的根目录中
猜你喜欢
  • 2019-12-16
  • 1970-01-01
  • 1970-01-01
  • 2017-08-13
  • 2019-01-31
  • 2020-12-07
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多