The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Global passwd file?

Discussion in 'General Discussion' started by Justin Wanstall, Feb 12, 2016.

  1. Justin Wanstall

    Justin Wanstall Registered

    Joined:
    Jan 21, 2016
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    UK
    cPanel Access Level:
    Root Administrator
    Because we develop client websites on test domains and want to preview people from browsing the sites (and google) until they are published on the final domain I would like to setup a global rule for a single passwd file to be used.

    So when the site is using a subdomain of our main test domain (i.e. xyz.example.com) the passwd file should be applied.

    I've tested it with SetEnvIfNoCase and it works fine.

    The problem I have is that AuthType can only be used inside <Directory /> so I can't add these rules in my WHM include editor.

    Any ideas how I do this? presumably with a template file?
     
  2. Justin Wanstall

    Justin Wanstall Registered

    Joined:
    Jan 21, 2016
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    UK
    cPanel Access Level:
    Root Administrator
    Found my own answer to this one...

    You can use a wildcard in <Directory/>

    Code:
    SetEnvIfNoCase ^HOST$ .+ unauthenticated
    SetEnvIfNoCase ^HOST$ ^(.*)\.testdomain\.com$ !unauthenticated
    
    
    <Directory ~ "/home/.*/public_html">
    AuthType Basic
    AuthName "Restricted Development Link"
    AuthUserFile "/home/.htpasswds/passwd"
    Require valid-user
    Order allow,deny
    Allow from env=unauthenticated
    Satisfy any
    </Directory>
    
     
  3. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,678
    Likes Received:
    653
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
Loading...

Share This Page