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.

Redirecting Error Pages

This page describes how to customise the error messages that appear when someone follows a link to a page that does not exist, as well as other common errors. By dropping a file called .htaccess in the root directory as shown in the example, every time one of these error pages is called, a page of your creation will be shown instead.

.htaccess:

AuthName 2020MEDIA
AuthType Basic
errordocument 404 /errors/err404.html
errordocument 500 /errors/err500.html

And so on for other pages. Click here for a full list of error pages. In the example above, the error pages would be found in a directory called 'errors', but it is up to you to call them whatever you want.
The .htaccess file is a plain text file, without any extension like .txt or .doc. It must be uploaded as ASCI - this is the default for most FTP programmes. Upload the file into the root directory ( also called the 'home' directory) and then attempt to view a page you know doesn't exist. You should get the page you created instead of the usual 'HTTP 404 Page does not exist' page. Once on the server its likely you won't be able to see the .htaccess file as it is a hidden file. You could rename the .htaccess.txt for editing purposes and then back to just .htaccess to enable them.

If you have read the page about password protecting pages, don't include the bit about AuthUserFile as it will password protect your entire website! Also, don't redirect 401 errors - this is used for password protecting of directories.

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

 

Final Tip:
See also Password Protecting Pages for more on htaccess.

Notes:
1 You can redirect any http code.
2 Links can be relative or absolute.
3 The AuthName must not include spaces. I.e "2020 Media" is not allowed.
4 The .htaccess file should be placed in the highest level direcory and it's
action will affect all lower directories unless there is another .htacess file to override them.
5 The file must be in unix text format. Dos text will not work. Be sure to
upload using ASCI mode in your ftp client.

Question: How do I transfer my local MS SQL file to server?

Solution:
1) First ensure you are on one of our Plesk servers. Otherwise you should use Enterprise Manager or SQL Management Studio to remotely connect and import your data.
2) Login to your Plesk Control Panel
3) Go to Database option and create new database and user
4) Now create database dump (backup) of your local database. And create .bak file
5) Upload .bak file to /httpdocs folder of your website. (FTP upload)
6) Contact support and request that we restore your database with following details
a. Your domain name
b. .bak file name and path to access that (e.g /httpdocs/mybackupfile.bak)
c. MS SQL DB name
7) We will confirm the restore of your database when it is complete.

Please use this connection string in your web.config file

 

add name="example" connectionString="Data Source=PLESK-5\SQLEXPRESS;Initial Catalog=exampleDbName;User ID=dbUserID;Password=dbUserPassword" providerName="System.Data.SqlClient"

See also www.connectionstrings.com

If you have any problems connecting to your database, please contact us.

Question:
How do I create and manage database on 2020Media's Plesk servers.

Solution:
To create a new database on your hosting account:

1. Go to Domains > domain name > Databases and click Add New Database.
2. Enter a name for the database.

We recommend that you choose a name that starts with a Latin alphabet symbol and comprises only alphanumeric and underscore symbols (up to 64 symbols).
3. Select the database type that you are going to use: MySQL or Microsoft SQL Server. Click OK.
4. To set up database administrator's credentials, click Add New Database User.
5. Type a user name and a password that will be used for accessing the contents of the database.
6. Click OK.

To import an existing database:

1. Go to Domains > domain name > Databases and click Add New Database.
2. Enter a name for the database. We recommend that you choose a name that starts with a Latin alphabet symbol and comprises only alphanumeric and underscore symbols (up to 64 symbols).
3. Select the database type that you are going to use: MySQL or Microsoft SQL Server. Click OK.
4. To set up database administrator's credentials, click Add New Database User.
5. Type a user name and a password that will be used for accessing the contents of the database. Click OK.
6. Click WebAdmin in the Tools group. An interface to phpMyAdmin (or ASPEnterpriseManager) database management tool will open in a separate browser window.

If you have a MySQL database:

1. Click Query window in the left frame, click the Import files tab,
2. Select the text file that contains the data and click Go.
3. Click the Insert data from a text file link.

If you have a MS SQL database:

1. Click the name of your database in the left frame
2. Click Query (the magnifying glass button)
3. Copy the text of your script into the text area and click Run Query.
4. Or, if you have a complex database, we can restore from your backup. See "Import MSSQL database to a plesk server" in the Support section

To manage your databases and their contents, use the web based database management tool accessible from Plesk control panel (Domains > domain name > Databases > Database name > WebAdmin).

Page 1 of 2

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