How to close access to pages

How to close access to pages

Digital Hits: 67

Sometimes there is a need to limit access to pages or any files of your website for certain user groups. The software of the Apache Web server has the built-in means for the solution of this task. Check them.

Instruction

1. At each request for any page of the website, the server checks existence in the folder where it is stored, the office file with the name "" .htaccess"". If it is, then the server, when processing request, will follow directives from this file. It is possible to place in it also directives of access restriction to pages or other documents of the website on any signs. It is possible to make it, having created such file in the normal text editor and having loaded into the folder of the server necessary to you. As these files are office, from the web visitor's browser they are not available.

2. To solve an access problem considerably place these directives in the htaccess file: Order Deny, Allow
Deny from allpoluchiv such instructions, the Web server will close access to all files and folders in this and all directories enclosed in it for one and all visitors.

3. It is possible to add to the total ban an exception for the users having a certain IP address: Order Deny, Allow
Deny from all
Allow from 77.84.20.18, 77.84.21.2V this example users whose IP 77.84.20.18 or 77.84.21.2, will not notice existence of any restrictions, and all others will not be allowed to pages. If you need such order of access - list the list of the resolved IP addresses through a comma.

4. If it is necessary to create on the contrary "black list" from the undesirable IP addresses, then directives should be changed thus: Order Allow, Deny
Allow from all
Deny from 77.84.20.18, 77.84.21.2 Access will be closed only for the visitors having IP 77.84.20.18 and 77.84.21.2, and the others will be freely passed. And in this option the list of the prohibited IP addresses should be listed through a comma.

5. If it is necessary to limit access not to all documents in the folder, and only to the separate file, then directives should look so: <Files ""hidden.html"">
Order Deny, Allow
Deny from all
Allow from 77.84.20.18
</Files> Here in the first line specified the file, access to which should be limited (hidden.html), and in the fourth line the exception of the prohibiting rule - IP of users to which access to the file is allowed is written.

6. It is similarly possible to limit access to group of files on a mask of their names: <Files "". (wma) of $"">
Order Deny, Allow
Deny from all
Allow from 77.84.20.18
</Files> Here in the first line specified a mask of names of files with limited access - the ban will extend to all files with the wma extension. In the fourth line, as well as in the previous example - IP of users on which restriction does not extend.

7. There is an opportunity to limit access to pages as the browser - in such a way it is possible to eliminate, for example, unwanted search robots: SetEnvIfNoCase user-Agent ^Microsoft.URL [NC,OR]
SetEnvIfNoCase user-Agent ^Offline.Explorer [NC,OR]
SetEnvIfNoCase user-Agent ^[Ww] eb[Bb]andit [NC,OR]
<head= "" post= "" limit get= "">
Order Allow, Deny
Allow from all
Deny from env=bad_bot
</limit> Here in the first three lines listed several undesirable types of browsers (on one on every line). Of course, when using such design you need to replace them not those which annoy your website.

Author: «MirrorInfo» Dream Team

Print