How to release a sub-directory protected with .htaccess?

6

I have .htaccess in my test environment developed in CakePHP and the .htaccess has authentication so that not anyone is accessing it.

Now I need to release a directory from the site, actually a CakePHP plugin, I need anyone to have access without requiring authentication.

<Directory /home/meusite/app/webroot>
  AuthType Basic
  AuthName "Ambiente de Desenvolvimento Teste"
  AuthUserFile /home/user/.htpasswd
  Require valid-user

  Options Indexes FollowSymLinks MultiViews
  AllowOverride All
  Order allow,deny
  allow from all
</Directory>

Question

How can I release a subdirectory from a directory protected by the .htaccess displayed above?

    
asked by anonymous 07.01.2014 / 19:28

2 answers

3

Add to the configuration file (usually httpd.conf ):

  

Note: <Directory ...>...</Directory> is not added directly to the file .htaccess

<Directory /path/to/dir/protected/unprotected>
     Satisfy Any
</Directory>

Source: @atonyc .

    
07.01.2014 / 20:05
1

Add the following settings

SetEnvIf Request_URI ^/{nomedosite}.*$ noauth=1
Allow from env=noauth
Satisfy any

Switch {nomedosite} to the path you expect to see in the URL.

Your .htaccess would look like this

for /home/meusite/app/webroot/.htaccess

<IfModule mod_rewrite.c>
  AuthType Basic
  AuthName "Ambiente de Desenvolvimento Teste"
  AuthUserFile /home/user/.htpasswd
  Require valid-user

  SetEnvIf Request_URI ^/meusite.*$ noauth=1

  Options Indexes FollowSymLinks MultiViews
  #AllowOverride All
  #Order Deny,Allow
  Satisfy any
  Deny from all
  Allow from env=noauth

  # Aqui vem as configurações do .htaccess padrão do CakePHP
  RewriteEngine On
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]
</IfModule>

There are other htaccess outside the webroot folder, stay tuned for that.

If you want to list the files within the freed folder add the code below that causes the htaccess rules to be ignored for the specified folder.

RewriteRule ^meusite.*$ - [PT]

Source: link

    
03.02.2014 / 14:45