It is necessary to close access to the entire site using htpasswd, but so that it remains open to a single URL, for example site.com/mj

Found a way:

SetEnvIf Request_URI "/mj" noauth=1 RewriteEngine on RewriteRule ^(.*) public/$1 [L] AuthType Basic AuthName "Private zone. Only for administrator!" AuthUserFile .../.htpasswd Require valid-user # Here is where we allow/deny Order Deny,Allow Satisfy any Deny from all Require valid-user Allow from env=noauth 
  • here is the answer to your question. I think in England you will understand stackoverflow.com/questions/3865374/… - splash58
  • Yes. All clear. But only there is access for a specific file, and all my requests will redirect to index.php <code> RewriteEngine on RewriteRule ^ (. *) Public / $ 1 [L] </ code> and mj is not a file or directory - Artem Sidorov
  • then, I think, it cannot be closed by regular means. close in code - splash58
  • There is a way after all. Added to description - Artem Sidorov
  • Good. You can write as an answer and mark it accepted to make it clear in the future that it works - splash58

1 answer 1

Found a way:

 SetEnvIf Request_URI "/mj" noauth=1 RewriteEngine on RewriteRule ^(.*) public/$1 [L] AuthType Basic AuthName "Private zone. Only for administrator!" AuthUserFile .../.htpasswd Require valid-user # Here is where we allow/deny Order Deny,Allow Satisfy any Deny from all Require valid-user Allow from env=noauth