Keep Server Online
  
If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.
  
or
  
 
  
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.
 |    |   
 | 
     Topic: Require password for all but one file | 
 |   
| Author | 
  | 
 
NotionCommotion
 
 
  Joined: 12 Nov 2014 Posts: 7
 
  | 
 Posted: Fri 16 Jan '15 15:43    Post subject: Require password for all but one file | 
     | 
 
  | 
 
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
  | 
 Posted: Fri 16 Jan '15 21:06    Post subject:  | 
     | 
 
  | 
 
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
 
  | 
 Posted: Sat 17 Jan '15 13:54    Post subject:  | 
     | 
 
  | 
 
Thanks glsmith,  it works for me too    | 
 
  | 
 
| Back to top | 
 | 
 
 
 
 
 | 
 
 
 |  
 
 |  
  |   
 |