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
-
Navigate to Domains > example.com > File manager
- Create a file
.htaccess
with the following directives:<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:
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:
location = /testdir/file.txt {
deny all;
}