About MartNet MartNet Technical Support
Home Services Support Members Software Contact
Search Support
MartNet WebMail

MartNet WebAdmin

Dialup Access
  Numbers

Domain Name
  Management

MartNet News /
  Status Info

NOC / System Status


Support Topics:
 MartNet WebAdmin
 Dial-up
 Virtual Hosting
 Web Site Construction
 Unix / Linux
 E-Mail
 Internet Chat
 Game Server Services
 Misc. Stuff
 Policies / Legal





FAQ's:
 MartNet WebAdmin
 Dial-up
 Virtual Hosting
 E-Mail
 Game Server Services
 Misc. FAQ's

Links:
 Privacy and Security
 Dial-up
 Web Development
 E-Mail
 Unix / Linux
 Game Server Services
 Misc. Support Links




MartNet Policies
Billing Dept.

Check Domain
Availability:



Using .htaccess
use .htaccess to restrict accessto all web documents by user and password.

The Restricted Access Directory

You've got some files on your site that are too big to email to people, but you don't want to put them up on your website for all to see. The easiest way to do this is through an .htaccess file, which is esstentially a password-protected directory.

The document "Restricted Information" is only available to user john with password orange and user sheri with password apple. The first time you click on "Restricted Information", your web browser should prompt you for a user name and password. If it does not you may be using a web browser which is not HTTP authentication capable.


Instructions

  • Create a folder in public_html to keep all your files you want password protected.

  • Go into that folder, and create a file called .htaccess

    Copy this info into the .htaccess file.

    AuthUserFile /home/USERNAME/public_html/YOURFOLDER/.htpasswd

    AuthName

    AuthType

    require valid-user

    For example if you were user jdoe with web documents in the local directory "/home/jdoe/public_html/goodstuff" that you wanted to restrict access to, your .htaccess might look like:

    AuthUserFile /home/joeu/public_html/goodstuff/.htpasswd
    AuthName joeu_goodstuff
    AuthType Basic

    require valid-user

    Note that .htaccess will not work if there are extra spaces after AuthUserFile.

  • The next step is to create a .htpassword file to keep track of the usernames and passwords of the people you want to allow access to.

    This file contains the passwords of the users.

    To create the .htpasswd file, type this in the prompt:

    htpasswd -c .htpasswd USERNAME

    for the first user (where someuser is the username). You will then be prompted twice for the user's password. The -c option causes the .htpasswd file to be created. For each additional user type:

    htpasswd .htpasswd NEXTUSER

NOTE: There is no correspondence between the usernames and passwords used for accounts on this server and usernames and passwords in any specific .htpasswd file. A user doesn't need to have an account on this system in order to be validated for access to files protected by HTTP-based authentication.


Further Study

This example limits access by user and password, however you can also restrict access by domain.
To find out more, check out this

This Web Site is proudly built upon an Open Source foundation:
Assembled with PHP Powered by Debian Linux Fueled by MySQL
Served by Apache

Home | Services | Support | Members | Software | Contact

MartNet - PO Box 42472 Philadelphia, PA 19101
Copyright 1996 - 2015 MartNet Communications LLC. All Rights Reserved.