如果在.htaccess文件的语句,在特定的目录时,启用密码保护只 [英] If statements in .htaccess files, to enable password protection when in specific directory only
问题描述
我有2张我的网站同步与颠覆。一个真人版和一个开发者版本。我喜欢做的是密码保护的开发者版本,使用.htaccess文件:
与AuthType基本
AuthName指令限制文件
的AuthUserFile ../.htpasswd
AuthPGAuthoritative关闭
需要用户开发
有没有一种方法来同步此.htaccess文件到真人版无密码保护呢?
我在想是这样
[文件是否存在../.htpasswd]
与AuthType基本
AuthName指令限制文件
的AuthUserFile ../.htpasswd
AuthPGAuthoritative关闭
需要用户开发
[/如果]
或
[如果currentDir = /路径/到/ dev /版]
...
[/如果]
Finaly找到了答案在这里: <一href="http://stackoverflow.com/questions/6143176/how-can-i-password-protect-dev-but-not-live-while-using-svn">How我可以用密码保护开发,但不能同时使用SVN生活?
如果 mod_setenvif
已启用可以设置不同的env瓦尔
SetEnvIfNoCase ^ HOST $ +未认证
SetEnvIfNoCase ^ HOST $ ^开发\ .EXAMPLE \ .COM $!未认证
I have 2 copies of my website synced with Subversion. One live version and one developer version. What I like to do is to password protect the developer version, using a .htaccess file:
AuthType Basic
AuthName "Restricted Files"
AuthUserFile ../.htpasswd
AuthPGAuthoritative Off
Require user dev
Is there a way to sync this .htaccess file to the live version without the password protection there?
I was thinking about something like
[if file exists ../.htpasswd]
AuthType Basic
AuthName "Restricted Files"
AuthUserFile ../.htpasswd
AuthPGAuthoritative Off
Require user dev
[/if]
or
[if currentDir = /path/to/dev/version]
...
[/if]
Finaly found the answer over here: How can I password protect dev but not live while using SVN?
If mod_setenvif
is enabled one can set different env vars
SetEnvIfNoCase ^HOST$ .+ unauthenticated
SetEnvIfNoCase ^HOST$ ^dev\.example\.com$ !unauthenticated
这篇关于如果在.htaccess文件的语句,在特定的目录时,启用密码保护只的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!