.htaccess with apache2

John Seth johnseth at phoenixwing.com
Tue May 23 16:31:12 MST 2006


One thing to keep in mind, is that an .htaccess file with password 
restrictions will require the entire directory to be password 
protected.  You cannot protect one file using .htaccess unfortunately.

If your file is located at http://my.domain.com/secret_page.html, try 
creating a subdirectory and placing the .htaccess file in that 
directory: http://my.domain.com/secret/file.html

In the .htaccess file place:

| AuthType Basic
AuthName "Password Required"
AuthUserFile /path/to/.htpasswd
Require valid-user|

And set up your password file where you specified.  As far as 
refreshing, it will not prompt for a username unless you close your 
browser window.  Sadly, that is common with any .htaccess supplied with 
apache's basic authentication method with .htaccess/.htpasswd files.

If you create web based authentication, using PHP or similar, you can 
create a "logout" script that will force apache to display a "403" 
error, causing apache to re-request authorization.

Hope that helps,

  Tony Evans
  Phoenix Wing Interactive
  johnseth at phoenixwing.com
  http://www.phoenixwing.com/




Miles Beck wrote:
> I have a file I would like to put up on my web server. But I would
> also like to password protect the file so that only myself can view
> it. This is a list of links I have organized into a html document. I'd
> like this to be accessible from my server so I can maintain it in one
> place.
>
> The problem is I have never been able to figure out .htaccess and
> refreshing or reloading the file will prompt for the password again.
>
> Is there a way to password protect it and also use a session id? This
> way I would not have to enter the password everytime I want to reload
> the file.
>
> I looked at pages.google.com but you have to publish the file to it
> can then be seen by everyone.
>
> Any help is appreciated.
>
> Thanks,
>
> -Miles
> ---------------------------------------------------
> PLUG-discuss mailing list - PLUG-discuss at lists.plug.phoenix.az.us
> To subscribe, unsubscribe, or to change  you mail settings:
> http://lists.PLUG.phoenix.az.us/mailman/listinfo/plug-discuss
>
>



More information about the PLUG-discuss mailing list