# Does nginx have a directive analogous to Apache's \<Directory\>?

**URL:** <https://www.ruby-forum.com/t/does-nginx-have-a-directive-analogous-to-apaches-directory/223625>\
**Category:** NGINX\
**Created:** [October 11, 2012, 2:03pm UTC](https://www.ruby-forum.com/t/does-nginx-have-a-directive-analogous-to-apaches-directory/223625 "2012-10-11T14:03:56Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![aris](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/258eb7/32.png) [@aris](https://www.ruby-forum.com/u/aris)\
**Post date:** [October 11, 2012, 2:03pm UTC](https://www.ruby-forum.com/t/does-nginx-have-a-directive-analogous-to-apaches-directory/223625/1 "2012-10-11T14:03:56Z")

</div>

Hello,

I’m trying to set up an nginx server to replace our current setup  
based on Apache. Our users have password protected directories (with  
directives in .htaccess files) which we need to keep protected in the  
new setup.

As far as I can see, nginx doesn’t have a Directory directive, but  
only a Location directive, which refers to URIs instead of file system  
paths. This means that if a directory is reachable through more than  
one URL, I have to include them all in one or more Location  
directives. For example:

[domain.com](http://domain.com), root: /home/user/public\_html  
[sub.domain.com](http://sub.domain.com), root: /home/user/public\_html/sub

If user protects [sub.domain.com/admin](http://sub.domain.com/admin) (directory  
/home/user/public\_html/sub/admin) I must make sure that both /admin in  
[sub.domain.com](http://sub.domain.com) and /sub/admin in [domain.com](http://domain.com) are protected with the  
same password file. I’d rather protect the directory itself, and not  
every URL through which visitors can access its contents.

So, does nginx have any mechanism that allows to refer to file system  
paths in configuration files, like Apache’s blocks do?

Thank you.

## Regards.

Juan R. Pozo - [http://html.conclase.net/](http://html.conclase.net/)

---

<div class="post-metadata">

**Author:** ![Juan\_RSPozo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/b5a626/32.png) [@Juan\_RSPozo](https://www.ruby-forum.com/u/Juan_RSPozo)\
**Post date:** [October 11, 2012, 10:37pm UTC](https://www.ruby-forum.com/t/does-nginx-have-a-directive-analogous-to-apaches-directory/223625/2 "2012-10-11T22:37:33Z")

</div>

No it doesn’t. You will need to specify all the locations.

Posted at Nginx Forum:

> **[Re: Does nginx have a directive analogous to Apache's ?](https://forum.nginx.org/read.php?2,231660,231684#msg-231684)**
>
> Hello, I'm trying to set up an nginx server to replace our current setup based on Apache. Our users have password protected directories (with directives in .htaccess files) which we need to keep protected in the new setup. As far as I can see, nginx...
