Answer the question
In order to leave comments, you need to log in
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
SetEnvIf Request_URI "(public_folder/)$" allow
Order allow,deny
Allow from env=allow
Satisfy any
<Files "protected_file.php">
AuthName "Member Only"
AuthType Basic
AuthUserFile /etc/apache2/.htpasswd
require user Vasily
</Files>
Answer the question
In order to leave comments, you need to log in
/public_folder/folder/.htaccess
<Files "protected_file.php">
AuthName "Member Only"
AuthType Basic
AuthUserFile /etc/apache2/.htpasswd
require user Vasily
Satisfy All
</Files>
AuthName "Member Only"
AuthType Basic
AuthUserFile /etc/apache2/.htpasswd
require valid-user
Satisfy All
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question