E
E
Essiar2018-11-28 14:00:43
Apache HTTP Server
Essiar, 2018-11-28 14:00:43

How to set different permissions for files and folders in .htaccess?

Hello
In general, I didn’t pick htaccess-s much, so I don’t know much about them, so I’m sorry right away
There is a web server (Apache)
The file structure is as follows

folder1/
folder2/
public_folder/
public_folder/file1.php
public_folder/folder/protected_file.php

The task is
to close All files and folders with basic authorization
The public_folder folder, open files and folders in it for everyone, but here's a trick
Inside public_folder subfolders, one file must be closed for everyone except one user (don't even ask why such a structure)
Type constructions
SetEnvIf Request_URI "(public_folder/)$" allow
Order allow,deny
Allow from env=allow
Satisfy any

don't work, don't know why (just doesn't ask for authorization)
Tried putting an extra .htaccess for public_folder with Satisfy any and
<Files "protected_file.php">
AuthName "Member Only"
AuthType Basic
AuthUserFile /etc/apache2/.htpasswd
require user Vasily
</Files>

, but the files are overridden by Satisfy any
Tell me, please, how to be?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
dodo512, 2018-11-29
@Essiar

/public_folder/folder/.htaccess

<Files "protected_file.php">
AuthName "Member Only"
AuthType Basic
AuthUserFile /etc/apache2/.htpasswd
require user Vasily

Satisfy All
</Files>

/public_folder/.htaccess
/.htaccess
AuthName "Member Only"
AuthType Basic
AuthUserFile /etc/apache2/.htpasswd
require valid-user

Satisfy All

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question