Articles in this section

How to prohibit access to a particular file from a browser in Plesk

kb: how-to Plesk for Linux ABT: Group A

Applicable to:

  • Plesk for Linux

Question

How to prohibit access from a browser to specific file (e.g. http//example.com/testdir/file.txt)?

Answer

Forbidding access can be done using webserver's additional directives or .htaccess file.

Log into Plesk go to Domains > example.com > Apache & nginx Settings and check the status of the option Serve static files directly by nginx:

Option is unchecked
  1. Navigate to Domains > example.com > File manager

  2. Create a file .htaccess with the following directives:

    CONFIG_TEXT: <Files "file.txt">
    Order Allow,Deny
    Deny from all
    </Files>

    Alternatevely navigate to Domains > example.com > Apache & nginx Settings and add the following nginx directive:

    CONFIG_TEXT: location ^~ /test { auth_basic "Restricted";
    auth_basic_user_file /var/www/vhosts/example.com/httodocs/testdir/.htpasswd;
    }

Option is checked

Go to Domains > example.com > Apache & nginx Settings. And add the following directives to Additional nginx directives field:

CONFIG_TEXT: location = /testdir/file.txt {
deny all;
}

Was this article helpful?

Comments

0 comments

Please sign in to leave a comment.