问题
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]
回答1:
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
来源:https://stackoverflow.com/questions/5471306/if-statements-in-htaccess-files-to-enable-password-protection-when-in-specific