【问题标题】:If statements in .htaccess files, to enable password protection when in specific directory only.htaccess 文件中的 if 语句,仅在特定目录中启用密码保护
【发布时间】:2011-03-29 10:47:32
【问题描述】:

我有 2 个与 Subversion 同步的网站副本。一个实时版本和一个开发者版本。我喜欢做的是使用 .htaccess 文件对开发者版本进行密码保护:

AuthType Basic
AuthName "Restricted Files"
AuthUserFile ../.htpasswd
AuthPGAuthoritative Off
Require user dev 

有没有办法在没有密码保护的情况下将此 .htaccess 文件同步到实时版本?

我正在考虑类似的事情

[if file exists ../.htpasswd]
  AuthType Basic
  AuthName "Restricted Files"
  AuthUserFile ../.htpasswd
  AuthPGAuthoritative Off
  Require user dev 
[/if]

[if currentDir = /path/to/dev/version]
...
[/if]

【问题讨论】:

标签: svn apache .htaccess


【解决方案1】:

终于在这里找到了答案: How can I password protect dev but not live while using SVN?

如果启用mod_setenvif,则可以设置不同的环境变量

SetEnvIfNoCase ^HOST$ .+ unauthenticated
SetEnvIfNoCase ^HOST$ ^dev\.example\.com$ !unauthenticated

【讨论】:

  • 我很高兴能够提供帮助。 :)
猜你喜欢
  • 1970-01-01
  • 2017-04-18
  • 1970-01-01
  • 2012-08-12
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多