htaccess的密码保护功能允许127.0.0.1而不是localhost [英] .htaccess password protection allows 127.0.0.1 but not localhost

查看:250
本文介绍了htaccess的密码保护功能允许127.0.0.1而不是localhost的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图用密码保护我的公共文件夹,以便任何试图访问外部被提示输入密码,而不是本地。到目前为止,我已完成了使用127.0.0.1工作,但不是localhost。很显然,我可以只使用的IP地址,但它更多的我想知道为什么它不工作的事实。我不喜欢被打败了!

I'm attempting to password protect my public folder so that anyone trying to access externally is prompted to enter a password but not locally. So far I have got it to work using 127.0.0.1 but not localhost. Obviously I COULD just used the ip address but it's more the fact I want to know why it doesn't work. I don't like to be defeated!

#Enable Password Protection
AuthName "Password Protected Server"
AuthType Basic
AuthUserFile c:\xampp\apache\security\.htpasswd
Require valid-user
Order allow,deny
Allow from localhost
Allow from 127.0.0.1
Satisfy Any

我的code迄今的积累:

My code so far is an accumulation of:

<一个href="http://www.groovypost.com/howto/how-to/htaccess-password-protect-apache-website-security/">http://www.groovypost.com/howto/how-to/htaccess-password-protect-apache-website-security/

<一个href="http://stackoverflow.com/questions/4323875/htaccess-password-protect-but-not-on-localhost">htaccess密码保护,但不能在本地主机

我在Windows 7上运行的XAMPP 1.7.3,如果有帮助。

I'm running XAMPP 1.7.3 on Windows 7, in case that helps.

任何援助将大大AP preciated!

Any assistance would be greatly appreciated!

推荐答案

听起来像是一个IPv6的问题。当你连接到站点127.0.0.1,阿帕奇认为该请求是在IPv4本地主机(127.0.0.1)的到来。但是,连接到本地主机时,阿帕奇认为该请求从本地主机IPv6的未来(:: 1)。

Sounds like an IPv6 issue. When you're connecting to the site with 127.0.0.1, Apache sees the request as coming from the IPv4 localhost (127.0.0.1). But, when connecting to localhost, Apache sees the request as coming from the IPv6 localhost (::1).

如果这是问题,你应该能够通过更换从本地主机允许行来解决它从:: 1允许行。

If this is the problem, you should be able to solve it by replacing the Allow from localhost line with a Allow from ::1 line.

这篇关于htaccess的密码保护功能允许127.0.0.1而不是localhost的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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