Configuring access restrictions for a site or its parts

Sometimes, when developing a site or in special configurations, it is required to restrict access to certain parts of the site, deny access to them for anonymous users, and provide password access.

In the PHP hosting control panel, it is possible to set rules for access to site folders using Basic authentication.

To configure access:

Settings should be done in the PHP hosting control panel https://cloud.realhost.pro

1. Go to the WWW - WWW domains section

configure-access-restrictions-for-site-or-its-parts.4

2. Select a site and click the Access button

configure-access-restrictions-for-site-or-its-parts.6

3. In the access editor, click the Add button

configure-access-restrictions-for-site-or-its-parts.8

4. Specify the folder to which you want to restrict access

configure-access-restrictions-for-site-or-its-parts.10

5. Enter the username and password of a user with access to this folder

configure-access-restrictions-for-site-or-its-parts.12

When the URL is called without authorization, the web server will return a 401 access error.

$ curl -I http://mysite.com/securefolder/
HTTP/1.1 401 Unauthorized
Server: nginx/1.18.0
Date: Tue, 24 Aug 2021 09:10:56 GMT
Content-Type: text/html; charset=UTF-8
Connection: keep-alive
WWW-Authenticate: Basic realm="Access limited by ISPmanager"