域特定htpasswd的条件 [英] Domain specific htpasswd conditions

查看:130
本文介绍了域特定htpasswd的条件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用通配符DNS系统,通过一个单一的Web应用程序会将所有子域名,并设置基于URL的第一部分(X.domain.com其中X为用户名)。

I am using a wildcard dns system that routes all subdomains through a single web app and sets a userid based on the first part of the URL (X.domain.com where X is the username).

我现在想修改我的htaccess文件中使用htpasswd的特定域,使有条件的httpauth。例如如果URL = password.domain.com启用httpauth。

I now want to edit my htaccess file to enable conditional httpauth using htpasswd for specific domains. e.g. if url = password.domain.com the enable httpauth.

我敢肯定,这是可能的,但有限的htaccess的知识。

I'm sure this is possible but have limited knowledge of htaccess.

推荐答案

您可以使用的 SetEnvIf之后 ,这里是从的这个帖子由汤姆·里克的。

#allows a single uri through the .htaccess password protection
SetEnvIf Request_URI "/testing_uri$" test_uri

#allows everything if its on a certain host
SetEnvIf HOST "^testing.yoursite.com" testing_url
SetEnvIf HOST "^yoursite.com" live_url
Order Deny,Allow

AuthName "Restricted Area"
AuthType Basic
AuthUserFile /path/to/your/.htpasswd
AuthGroupFile /
Require valid-user

#Allow valid-user
Deny from all
Allow from env=test_uri
Allow from env=testing_url
Allow from env=live_url
Satisfy any

这篇关于域特定htpasswd的条件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆