2017-11-17 2 views
0

これは可能ですが、いくつかの異なるURLといくつかの異なるサブドメインでホストされているアプリケーションがあります。.htaccess異なる.htpasswdファイル用の文

これらはそれぞれ基本的な保護セクション(htpasswdを使用)を持っています。

私は、異なるファイルを指す別の束を持つよりむしろ、1つのhtaccessファイルを持つことができたいと思います。

I持って、次のファイル構造:

の.htaccess の.htpasswd-domainone の.htpasswd-domaintwo の.htpasswd-domainthree

このような何かをする方法はありますか?

<If "%{HTTP_HOST} == 'domainone'"> 
AuthUserFile /file/location/.htpasswd-domainone 
</If> 

<If "%{HTTP_HOST} == 'domaintwo'"> 
AuthUserFile /file/location/.htpasswd-domaintwo 
</If> 


<If "%{HTTP_HOST} == 'domainthree'"> 
AuthUserFile /file/location/.htpasswd-domainthree 
</If> 

サブドメインを考慮しますか?

答えて

0

のApache 2.4、次のような作品と仮定:

Options -Indexes 

AuthName Login 
AuthType Basic 
require valid-user 

<If "%{HTTP_HOST} == 'sub.domain1.com'"> 
AuthUserFile /var/www/html/admin/.htpasswd-domain1 
Deny from all 
Satisfy any 
</If> 
<ElseIf "%{HTTP_HOST} == 'sub2.domain1.com'"> 
AuthUserFile /var/www/html/admin/.htpasswd-domain2 
Deny from all 
Satisfy any 
</ElseIf> 
<Else> 
Allow from all 
Satisfy any 
</Else> 
関連する問題