的.htaccess / .htpasswd则绕过,如果在某一个IP地址 [英] .htaccess / .htpasswd bypass if at a certain IP address

查看:427
本文介绍了的.htaccess / .htpasswd则绕过,如果在某一个IP地址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有可能有一个.htaccess / htpasswd的访问控制设置为给定的目录,但如果是从一个特定的IP地址,绕过登录/密码认证?

Is it possible to have an .htaccess/.htpasswd access control setup for a given directory, but if they are from a specific IP address, bypass the login/password authentication?

我知道你可以做这样的事情在.htaccess文件中:

I know you can do something like this in the .htaccess file:

order deny,allow
deny from all
allow from 000.000.000.000

但是,如果你购买的东西沿着这些路线:

But if you add something along these lines:

AuthType Basic
AuthName "restricted area"
AuthUserFile /path/to/.htpasswd
require valid-user

然后,它会提示输入密码。有没有办法做一个的if / else类型的设置,或一些其他的解决方案,使用户作为一个给定的IP(或一组IP地址的)没有得到提示输入密码,但其他人呢?

Then it prompts for the password. Is there any way to do an if/else type setup, or some other solution so that users as a given IP (or set of IPs) don't get prompted for a password, but everyone else does?

推荐答案

有关版本2.2.X您可以使用以下...

For versions 2.2.X you can use the following...

AuthUserFile /var/www/mysite/.htpasswd
AuthName "Please Log In"
AuthType Basic
require valid-user
Order allow,deny
Allow from xxx.xxx.xxx.xxx
satisfy any

显然更换的路径usersfile和IP地址,您将要为其绕过认证。

Obviously replace the path to your usersfile and the ip address which you would like to bypass the authentication.

的具体情况进一步说明,可以发现:<一href="http://httpd.apache.org/docs/2.2/howto/auth.html">http://httpd.apache.org/docs/2.2/howto/auth.html

Further explanation of the specifics, can be found at: http://httpd.apache.org/docs/2.2/howto/auth.html

这篇关于的.htaccess / .htpasswd则绕过,如果在某一个IP地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆