Skip to content

Instantly share code, notes, and snippets.

@fmtarif
Last active July 9, 2021 00:59
Show Gist options
  • Save fmtarif/bf9503530a8d425ab8a2 to your computer and use it in GitHub Desktop.
Save fmtarif/bf9503530a8d425ab8a2 to your computer and use it in GitHub Desktop.

Revisions

  1. fmtarif revised this gist Jan 9, 2017. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion .htaccess-basic-auth-exclude-url
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,6 @@
    #for Apache 2.4
    SetEnvIf Request_URI ^/tracking/logs auth=1
    SetEnvIf Request_URI ^/siempo/logs auth=1
    SetEnvIf Request_URI ^/anotherdir/logs auth=1

    AuthName "Please login"
    AuthType Basic
  2. fmtarif revised this gist Jan 9, 2017. No changes.
  3. fmtarif revised this gist Jan 9, 2017. 1 changed file with 19 additions and 0 deletions.
    19 changes: 19 additions & 0 deletions .htaccess-basic-auth-exclude-url
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,22 @@
    #for Apache 2.4
    SetEnvIf Request_URI ^/tracking/logs auth=1
    SetEnvIf Request_URI ^/siempo/logs auth=1

    AuthName "Please login"
    AuthType Basic
    AuthUserFile "/srv/http/.htpwd"

    # first, allow everybody
    Order Allow,Deny
    Satisfy any
    Allow from all
    Require valid-user
    # then, deny only if required
    Deny from env=auth
    #END - for Apache 2.4


    #WORKS with apache < 2.4
    # Basic authentication for site excluding specific url patterns
    # Do the regex check against the URI here, if match, set the "allow" var

  4. fmtarif revised this gist Jun 23, 2015. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion .htaccess-basic-auth-exclude-url
    Original file line number Diff line number Diff line change
    @@ -6,7 +6,7 @@ SetEnvIf Request_URI ^/uploads allow

    AuthType Basic
    AuthName "restricted area"
    AuthUserFile /home/.htpasswd #chage to your .htpasswd file location
    AuthUserFile /home/.htpasswd #chage to your .htpasswd file ABSOLUTE path

    # Setup a deny/allow
    Order Deny,Allow
  5. fmtarif renamed this gist Jun 23, 2015. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  6. fmtarif created this gist Feb 26, 2015.
    20 changes: 20 additions & 0 deletions .htaccess-basic-auth
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,20 @@
    # Basic authentication for site excluding specific url patterns
    # Do the regex check against the URI here, if match, set the "allow" var

    SetEnvIf Request_URI ^/api allow
    SetEnvIf Request_URI ^/uploads allow

    AuthType Basic
    AuthName "restricted area"
    AuthUserFile /home/.htpasswd #chage to your .htpasswd file location

    # Setup a deny/allow
    Order Deny,Allow
    # Deny from everyone
    Deny from all
    # except if either of these are satisfied
    Satisfy any
    # 1. a valid authenticated user
    Require valid-user
    # or 2. the "allow" var is set
    Allow from env=allow