Basic Auth not excluding urls

Discussion in 'Apache Migration/Compatibility' started by Frank Cuzziod, Jan 26, 2017.

  1. Frank Cuzziod

    Frank Cuzziod New Member

    Hi. I need to setup Apache Basic Auth to ask usr/password in all pages of my website, and exclude some of them.

    I've done this in several ways that Apache accepts (methods 1 through 3) and, in Apache, they're working flawlessly.

    Now, when I upload the same .htaccess to my hosting provider (Banahosting.com), their LiteSpeed server is blocking all pages, it's ignoring completely the directives to exclude those specific pages.

    The .htaccess file is in the directory I would like the access restrictions to be applied, and contains this (right now METHOD 1 is active, all other commented out, but in Apache they work OK):

    ---------------------------------------------------------------
    AuthType Basic
    AuthName "Login"
    AuthUserFile "security/.htpasswd"

    # METHOD 1
    SetEnvIf Request_URI ^/private/(page.php|ajax/.*) noauth=1

    <RequireAny>
    Require env noauth
    Require env REDIRECT_noauth
    Require valid-user
    </RequireAny>

    # METHOD 2
    #Require expr %{REQUEST_URI} = m#^/private/page.php#
    #Require expr %{REQUEST_URI} = m#^/private/ajax/.*#
    #Require valid-user

    # METHOD 3
    #Require expr %{REQUEST_URI} in {'/private/page.php', '/private/ajax/res1.php', '/private/ajax/res2.php'}
    #Require valid-user

    ---------------------------------------------------------------

    Do you support any synthax to tell LiteSpeed to "accept" those urls?
     
  2. mistwang

    mistwang LiteSpeed Staff

    Currently "Require env" and "Require expr" are not supported. We will add that to our to-do list.
     
  3. Frank Cuzziod

    Frank Cuzziod New Member

    Oh, so... is there any way to exclude urls off basic auth? by using some other directive?
     
  4. mistwang

    mistwang LiteSpeed Staff

    in the directory need to be excluded add

    to the .htaccess. see if it works or not.
     
  5. Frank Cuzziod

    Frank Cuzziod New Member

    Yes, it works, in fact I used this in directories that had some files to be excluded:

    <FilesMatch "file-a|file-b">
    Order allow,deny
    Allow from all
    Satisfy any
    </FilesMatch>

    Thanks.

    Now I really need to setup AuthUserFile for several different environments.

    It would be awesome if I could use the <If> directive, but it's not available, right? Is there a list of directives available for LiteSpeed so I can work my way around?

    Thanks again mistwang!
     

Share This Page