Release subdirectory through . htaccess

Asked

Viewed 1,128 times

2

How do I release a specific subdirectory (and all its files) via . htaccess?

How do I use "friendly url" and through .htaccess I block everything that does not suit, I would like to know how to "free" the access to a specific folder and all the files in it.

OBS: the command <Directory /path/to/dir/protected/unprotected> Satisfy An </Directory> did not solve my problem, as the same should be put in the httpd.conf and I don’t have access to it. In the question quoted as "answered" the author probably has this access, and thus my question is not answered yet. I’ll take a new test.

Test result: In local tests in the archive httpd.conf answer of the question marked as answered works perfectly, but if the same be placed in a .htaccess the error is returned

Internal Server Error

For my problem I don’t have access to the file httpd.conf and the same should be done in the archive .htaccess. Hence the question of how to release a specific directory via .htaccess.

  • Which version of apache are you using? 2.2 or 2.4? could you add your . htaccess to question content for better understanding?

  • In case I would just make a certain folder for "public" access along with all its internal content.

  • I think my answer satisfies your problem... =)

1 answer

2

Imagining the following structure:

public_html/
├── pasta_x/
├── pasta_y/
└── pasta_z/

Let’s use as an example that you want the folder pasta_y is publicly accessed, then the following code will be added to your . htaccess:
EDITED: If the option Options +Indexes is enabled on your virtualhost.

<Directory “caminho/absoluto/pasta_y/”>
    #para Apache 2.2
    Order Allow, Deny
    Allow From All

    #para Apache 2.4
    Require all granted
</Directory>

If the above code does not work, you can create a . htaccess file inside the directory pasta_ywith the following content:

#para Apache 2.2
Order Allow, Deny
Allow From All

#para Apache 2.4
Require all granted

Browser other questions tagged

You are not signed in. Login or sign up in order to post.