Get the App
SLTechnology News&Howtos  ›  Network Security  › 

What should I do to restrict user access to a directory?

Shulou Source: shulou.com Published: 2022-06-01 07:26:58 10月03日 Update

1. Enter the cd / data/www directory

two。 Create a tmp file

Mkdir tmp

What should I do to prevent users from accessing the tmp directory?

1. Open the virtual host configuration file and add code

Vi / usr/local/apache2/conf/extra/httpd-vhosts.conf

RewriteEngine on

RewriteCond% {HTTP_HOST} ^ www.test.com$ [OR]

RewriteCond% {HTTP_HOST} ^ www.aaa.com$-add a row

RewriteRule ^ / (. *) $http://ww.lizheng.com/$1 [Rene301 Magi L] (marked with / beginning, $1)

# Rewritecond% {HTTP_USER_AGENT} ^. * curl.* [NC,OR]

# Rewritecond% {HTTP_USER_AGENT} ^. * chrome* [NC]

# Rewritecond. *-[F]

Rewritecond% {REQUEST_URI} ^. * / tmp/.* [NC] condition

RewriteRule. *-[F] rejected as a result

two。 Restart, load

Apachectl-t

Apachectl graceful

3. test

Tags: Directories files users one line hosts code conditions tags results virtual hosts tests configurations restrictions Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Tech Info OPPO Reno Shulou Information Linux Microsoft