Search code examples
.htaccesscloudcache-control.htpasswd

htaaccess password protection


i have a development version of a site and so am using password protection. The problem is i am using cloud for managing static contents like images. css, js etc

Ste URL : http://www.example.com
Static url: http://cdn.example.org

Where cd, is a "A" type entry. When i updated my htaccess for password protection, it is asking multiple times

AuthUserFile /var/www/html/example.com/.htpasswd
AuthType Basic
AuthName "My Secret Folder"
Require valid-user

So how can i remove htpassword for the statc domain(http://cdn.example.org)


Solution

  • You can setup your .htaccess like this:

    SetEnvIfNoCase Host ^cdn\. CDN
    
    AuthUserFile /var/www/html/example.com/.htpasswd
    AuthType Basic
    AuthName "My Secret Folder"
    Require valid-user
    Satisfy    any
    Order      deny,allow
    Deny from  all
    Allow from env=CDN