When you want to visit some site you type the address of the site in an address line. Web Browser sends the request and awaits an answer in order to open the site. Web-server is a program which takes that request and processes it by sending you the site you needed.
The most popular web-server in the internet is web-server Apache. There are a lot of different releases of this server which were created for various tasks. Our company for submitting hosting services uses the web-server Apache which can work with Russian encodings.
How manage Apache?
You can manage Apache by adding to the fail “.htaccess” special directives. As a matter of fact, these are just instructions which tell the web-server what to do in different situations. The fail “.htaccess” – is a text file which can be created in the server using for example file manager of hosting control panel. Besides, it can be made on the computer and then you can download it to the server using protocol FTP.
Directives of the file “.htaccess” function for directory in which the file take place and for subdirectories if they do not have the files “.htaccess”. Directives in the file “.htaccess” that take place in subdirectory remold analogous directives in overlying “.htaccess”. That is to say: directives that were defined in directory and were not defined in subdirectory keep on affecting all the inserted subdirectories.
Usually one file “.htaccess” is used for the whole site. In this case it is placed in the directory public_html and it influences root directory and its subdirectories.
What directives you can use?
In our hosting you can use all the Apache directives which are applicable to the file “.htaccess”.
How can you set a password for directory?
you want web-server Apache require a password when accessing protected
directory then you have to place to the directory file “.htaccess” in which
should be mentioned these directives:
- AuthName ProtectedZone. Instead of ProtectedZone you can write whatever you want. It is the name of protected area and it will come into sight when asking for a password. So it is some kind of a screen prompt. If you want to use Russian letters or words you will have to use quotation marks. Exampe: AuthName “enter the password”
- AuthType Basic. It is a method of encrypting the password. Almost always this kind of encryption is used. Example: AuthType Basic
- AuthUserFile /complete_path_to_the_file,/.htpasswd. That is a way to the file in which will be passwords and logins taking place. It can have any name and be at any directory. The only thing that matters is that web-server could read it and that requires installation of corresponding access permissions to that file (in our server – 644). But traditionally these files are called “.htpasswd”. Example: AuthUserFile/home/test/www/site1/public_html/.htpasswd
- Require valid-user. This line says that access to protected directory will be permitted to all users whose passwords and logins take place in the file “.htpasswd”. If it is necessary to give access to specific people then you should point ‘require user’
Users’_logins_through_the_gap. Example: require user vasya lolya petya.
Example: require valid-user.
How to edit the file “.htaccwd”?
The file of passwords .htpasswd – is a text file. Every user is described in it by one line of the kind: login: ciphered password. For encryption passwords a special program htpasswd is used. Pay attention to the fact that it is impossible just to type a password to the file manually. The password has to be ciphered by the program htpasswd.
If file .htpasswd does not exist yet, then program htpasswd has to be launched with the key -c: htpasswd –c /complete_path_to_the_file/.htpasswd user’s login
Example: htpasswd –c/home/login/domains/site1/public_html/.htpasswd vasua
Besides, the program is going to create a file .htpasswd and inquire a user’s password and it will make a record about user with pointed login and password in the file. When adding some other users and changing passwords the program acts the same way but without the key -c. To delete a user you should open the file .htpasswd using text editor and then delete a line with his login and password.
To set a password for any file of your site you can do by using web-interface of file manager hosting control panel DirectAdmin. To do it you have to press the button Protect which stands opposite required file and then set a password.
Where can I get the necessary information?
To find out some information about file settings .htaccess and web-server Apache you can by looking through official site of the program product – apache.org. There is detailed information and examples of working with this web-server.