UK Sales: 0800 035 6364 | sales@2020media.com | We'll Call You

Password Protected Pages

 

This page describes how to protect sections of the web site with a password. This can be used to only allow access to particular people.

 

NOTE: You can only protect directories, not individual files.

You can password protect any directory by placing the files .htaccess and .htpasswd into the directory you wish to protect.

Examples are as follows:
.htaccess:

AuthUserFile /data/htdocs/a/adomainname/directoryname/.htpasswd
AuthName 2020MEDIA
AuthType Basic

<Limit GET POST PUT>
require valid-user
</Limit>


.htpasswd (examples only!- you must create your own usernames) :

user1:BUk/xqLqKF.2k
user2:rNa5zU.OdDsqY


How to Use:
The first line "AuthUserFile" contains the path to your directory. This is normally the first letter of the domain name of your site, followed by the domain name itself ( but without .co.uk or. com ). ie: if your website was www.mother.co.uk, and you wanted to protect a directory called 'members' , the AuthUserFile line would look like this:

AuthUserFile /data/htdocs/m/mother/members/.htpasswd

The path given above is an example only - please check with us for the correct path to your site.
The information in the password file must be generated by a program.

How to create the .passwd file: This is a file that is in your directory that will contain users passwords. The passwords are encrypted, so if some one sees the file, they will not be able to see the password.

To generate the username and password click here, and entering username/ password combinations that will allow access to the site

Create these two files in a plain text editor and save them with the filenames shown. Do not give them any extension (like .txt or .doc) Upload both of these files in ASCI mode into the directory you are trying to protect and then attempt to view the directory with a browser. You should be prompted for your username and password. Once you have logged in once, you will normally stay logged in until you close the browser window.

For further information consult any of the many books on Apache Web server, or see http://www.apache.org.

Final Tip:

You can change "AuthName" to anything you want - this is just a title that shows up on the security login box when someone tries to view the protected directory.

See also Redirecting Error Pages and HTTP error codes for more on htaccess.

2020Media is a leading provider of small business Wi-Fi hotspots. If you want to offer free Wi-Fi to your customers or users, our service could be exactly what you are looking for. Our Hotspots are managed in the cloud, ultra-reliable and give you loads of information about behaviour patterns of your users. Read More   Read more...
2020Media introduces Moodle Hosting - UK servers and UK Moodle experts setup your site ready to use. Read more...
Special Offer for Longer Registration Periods Register or renew a .com, .net or .org domain name for 5 years we'll include 1 year free*. Read more...
2020Media is now offering zero-click installation of the popular TYPO3 content management system. Read more...

Our blog is regularly updated with news, tips and industry opinion.

Clients

  • AggieWestons
  • baker-and-mckenzie
  • arts-council-england
  • Big Finish
  • barratt-developments-logo
  • City-of-Lincoln-council-logo
  • brora-logo
  • DenisMacShane
  • Construction-Industry-Council
  • colchester