logo
Apache Lounge
Webmasters

 

About Forum Index Downloads Search Register Log in RSS X


Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.

or

Bitcoin

A donation makes a contribution towards the costs, the time and effort that's going in this site and building.

Thank You! Steffen

Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
Post new topic   Forum Index -> Apache View previous topic :: View next topic
Reply to topic   Topic: Require password for all but one file
Author
NotionCommotion



Joined: 12 Nov 2014
Posts: 7

PostPosted: Fri 16 Jan '15 15:43    Post subject: Require password for all but one file Reply with quote

Hi,

I would like my entire website to be password protected except for one file called allowThisFileWithoutPassword.php.

How could this be accomplished. Below is my attempt.

Thank you

Code:

<VirtualHost *:80>
    ServerName example.com
    ServerAlias *.example.com
    # ServerSignature Off

    ErrorDocument 404 /error-404.html

    DocumentRoot /var/www/html

    <Directory "/var/www/html">

        #allow from all
        Options +Indexes

        # Development server only.
        AuthType Basic
        AuthName "Restricted Files"
        #AuthBasicProvider file
        AuthUserFile /var/www/private
        Require user Michael

        #Allow given directories or files without password.
        #SetEnvIf Request_URI "/var/www/html/bla/" allow
        SetEnvIf Request_URI "/var/www/html/allowThisFileWithoutPassword.php"  allow
        Order allow,deny
        Allow from env=allow
        Satisfy any

    </Directory>
</VirtualHost>
Back to top
glsmith
Moderator


Joined: 16 Oct 2007
Posts: 2268
Location: Sun Diego, USA

PostPosted: Fri 16 Jan '15 21:06    Post subject: Reply with quote

This works for me

AuthName "Protection"
AuthType Basic
AuthUserFile /var/www/soilent_green/.htpasswd
Require user plankton

<Files "protectmenot.php">
Satisfy Any
Allow from all
</Files>
Back to top
NotionCommotion



Joined: 12 Nov 2014
Posts: 7

PostPosted: Sat 17 Jan '15 13:54    Post subject: Reply with quote

Thanks glsmith, it works for me too Very Happy
Back to top


Reply to topic   Topic: Require password for all but one file View previous topic :: View next topic
Post new topic   Forum Index -> Apache