简体   繁体   English

如何在Vagrantfile的htaccess中允许IP

[英]How can I allow IP in htaccess from Vagrantfile

I am attempting to limit wp-admin access to a specific set of IPs. 我试图限制wp-admin访问一组特定的IP。 This works great on the live server, but when viewing locally I am getting a 403 forbidden error. 这在实时服务器上运行良好,但在本地查看时,我收到403 forbidden错误。

The site is developed using Vagrant and so I have set the following line in the Vagrantfile 该站点是使用Vagrant开发的,因此我在Vagrantfile设置了以下行

    config.vm.network "private_network", ip: "192.120.33.15"

So in /wp-admin I have the following .htaccess file: 所以在/wp-admin我有以下.htaccess文件:

order deny,allow
deny from all
allow from 192.120.33.15

I have attempted many variations and loading multiple IPs with no luck. 我尝试了很多变种并加载多个IP而没有运气。 Any suggestions on how I can gain access when viewing the site locally? 有关如何在本地查看网站时获取访问权限的任何建议?

If you configure a private network as you mentioned 如果您按照提到的那样配置专用网络

config.vm.network "private_network", ip: "192.120.33.15"

you can connect to your host on the following interface 192.120.33.1 . 您可以通过以下界面192.120.33.1连接到主机。 Simply add this IP then in your .htaccess file and you will be able to access your webserver from your host. 只需将此IP添加到.htaccess文件中,即可从主机访问您的网络服务器。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM