我开发具有到两个远程服务器在本地以及上运行的应用程序。一个目录是使用的htpasswd
文件保护。这是我怎么也得定义路径在的htaccess的
文件:的htpasswd
文件
I am developing an application that has to run both locally as well as on a remote server. One directory is protected using an htpasswd
file. This how I have to define the path to the htpasswd
file in the htaccess
file:
AuthUserFile ../app/some-folder/.htpasswd
不幸的是,应用
文件夹需要在服务器上,但我没有那个地方。相反,该路径必须是这样的:
Unfortunately the app
folder is required on the server, but I don't have that locally. Instead, the path has to look like this:
AuthUserFile /Volumes/some/very/long/path/some-folder/.htpasswd
是否有可能给我们EN if / else语句来根据当前主机关掉这个AuthUserFile文件路径(修改或更好的,不需要任何身份验证本地)?还是有另一种解决方法,以使对我的两个本地和远程主机文件的工作?
Is it possible to us en if/else statement to switch this AuthUserFile path according to the current host ( Or better yet, don't require any authentication locally)? Or is there another workaround to make this file work on both my local and the remote host?
没关系,我理解了它。我把这个在我的的.htaccess
:
Never mind, I figured it out. I put this in my .htaccess
:
AuthName "Protected"
AuthType Basic
AuthUserFile path/to/.htpasswd
Require valid-user
Order deny,allow
Deny from all
Allow from 127.0.0.1
Satisfy Any
这允许从本地IP发去通过无需输入密码的任何连接。并不完美,但工作在我的处境。
This allows any connections made from the local IP to go through without entering a password. Not perfect, but works in my situation.