How can I password protect dev but not live while using SVN?(如何在使用 SVN 时密码保护开发人员但不能使用?)
问题描述
我们有这个工作流程:开发在 dev.example.com 上完成更改提交到 SVN,然后导出到实时站点.实时站点位于 www.example.com
We have this workflow: Development is done on dev.example.com Changes are committed to SVN, then exported to live site. Live site is at www.example.com
我想用密码保护 dev.example.com,但如果我用 .htaccess 来做,我们将在现场使用相同的 .htaccess,它也会得到密码保护.
I want to password protect dev.example.com, but if I do it with .htaccess, we will be using the same .htaccess at live site and it will get password protected too.
我们使用的是 Dreamhost 共享主机,我有 SSH 访问权限,但我无法编辑 Apache 的配置 .conf 文件.
We are using Dreamhost shared hosting, I have SSH access, but I can not edit Apache's configuration .conf files.
我们不想在 SVN 中为 dev&live 提供单独的 .htaccess 文件并忽略 .htaccess,因为对 .htaccess 也进行了更新.
We don't want to have separate .htaccess files for dev&live and ignore .htaccess in SVN because updates are done to .htaccess as well.
那我该怎么办?
推荐答案
如果在服务器上启用了 mod_setenvif,您可以将其添加到您的 .htaccess 文件中:
If mod_setenvif is enabled on the server, you could add this to your .htaccess file:
SetEnvIfNoCase ^HOST$ .+ unauthenticated
SetEnvIfNoCase ^HOST$ ^dev.example.com$ !unauthenticated
AuthType Basic
AuthName "Secured"
AuthUserFile /path/to/.htpasswd
Require valid-user
Order allow,deny
Allow from env=unauthenticated
Satisfy any
这基本上是设置一个名为unauthenticated"的环境变量,但如果 HOST(浏览器请求的主机)恰好是dev.example.com",则取消设置它.在 Directory 指令中,满足任何条件"告诉 Apache 在满足任何一个条件时允许该请求.这意味着在dev.example.com"上,不会设置环境变量,因此您需要输入密码.对于任何其他主机,将设置该变量,以便 Apache 不会要求提供凭据.
What this basically does is it sets an environment variable called "unauthenticated" but unsets it if the HOST (the host requested by the browser) is exactly "dev.example.com". In the Directory directive, the "satisfy any" tell Apache to allow the request if any one of the conditions are met. This means that on "dev.example.com", the environment variable won't be set and as such, you'll be required a password. For any other hosts, the variable will be set so Apache won't ask for credentials.
这篇关于如何在使用 SVN 时密码保护开发人员但不能使用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何在使用 SVN 时密码保护开发人员但不能使用?
- Laravel 仓库 2022-01-01
- SoapClient 设置自定义 HTTP Header 2021-01-01
- 从 PHP 中的输入表单获取日期 2022-01-01
- 带有通配符的 Laravel 验证器 2021-01-01
- 正确分离 PHP 中的逻辑/样式 2021-01-01
- 没有作曲家的 PSR4 自动加载 2022-01-01
- Mod使用GET变量将子域重写为PHP 2021-01-01
- 如何定位 php.ini 文件 (xampp) 2022-01-01
- Oracle 即时客户端 DYLD_LIBRARY_PATH 错误 2022-01-01
- PHP Count 布尔数组中真值的数量 2021-01-01
