# Using autoindex and the php index file

**URL:** <https://www.ruby-forum.com/t/using-autoindex-and-the-php-index-file/212759>\
**Category:** NGINX\
**Created:** [October 12, 2011, 10:23pm UTC](https://www.ruby-forum.com/t/using-autoindex-and-the-php-index-file/212759 "2011-10-12T22:23:45Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![luislavena](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/0ea827/32.png) [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Post date:** [October 12, 2011, 10:23pm UTC](https://www.ruby-forum.com/t/using-autoindex-and-the-php-index-file/212759/1 "2011-10-12T22:23:45Z")

</div>

Hi.

My config looks like this:

location / {  
…  
index index.php;  
autoindex off;  
}

…

location /autoindx\_dir/ {  
autoindex on;  
}

location /autoindx\_dir/not/ {  
autoindex off;  
}

also I have the php cgi options.  
The problem is that nginx opens the index.php for my root directory if i  
open only the domain. If I go to the “autoindx\_dir” directory I see the  
directory files like i want. But if I open “autoindex\_dir/not” I see  
also the hole directory although i have a index.php.

Whats wrong ?

Posted at Nginx Forum:

> **[using autoindex and the php index file](https://forum.nginx.org/read.php?2,216607,216607#msg-216607)**
>
> Hi. My config looks like this: location / { ... index index.php; autoindex off; } ... location /autoindx\_dir/ { autoindex on; } location /autoindx\_

---

<div class="post-metadata">

**Author:** ![bimbonius](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/b782af/32.png) [@bimbonius](https://www.ruby-forum.com/u/bimbonius)\
**Post date:** [October 12, 2011, 10:58pm UTC](https://www.ruby-forum.com/t/using-autoindex-and-the-php-index-file/212759/2 "2011-10-12T22:58:18Z")

</div>

On 12.10.2011 22:22, bimbonius wrote:

> ```
> autoindex off;
> 
> ```
> 
> }
> 
> also I have the php cgi options.  
> The problem is that nginx opens the index.php for my root directory if i  
> open only the domain. If I go to the “autoindx\_dir” directory I see the  
> directory files like i want. But if I open “autoindex\_dir/not” I see  
> also the hole directory although i have a index.php.
> 
> Whats wrong ?

Propably because you set up ‘index index.php;’ in location / and not in  
/autoindex\_dir/not/. Move it outside location /, like just into http {}

Read [GitHub - nginxinc/nginx-wiki: ARCHIVED -- Source for the now archived NGINX Wiki section of https://www.nginx.com · GitHub](http://wiki.nginx.org/HttpCoreModule#location)

– Piotr.

---

<div class="post-metadata">

**Author:** ![bimbonius](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/b782af/32.png) [@bimbonius](https://www.ruby-forum.com/u/bimbonius)\
**Post date:** [October 12, 2011, 11:26pm UTC](https://www.ruby-forum.com/t/using-autoindex-and-the-php-index-file/212759/3 "2011-10-12T23:26:03Z")

</div>

Shame on me ☹  
Thx very much

Posted at Nginx Forum:

> **[Re: using autoindex and the php index file](https://forum.nginx.org/read.php?2,216607,216611#msg-216611)**
>
> Hi. My config looks like this: location / { ... index index.php; autoindex off; } ... location /autoindx\_dir/ { autoindex on; } location /autoindx\_
