# Basic question

**URL:** <https://www.ruby-forum.com/t/basic-question/189025>\
**Category:** NGINX\
**Created:** [May 22, 2010, 7:57am UTC](https://www.ruby-forum.com/t/basic-question/189025 "2010-05-22T07:57:29Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![gyan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/838e76/32.png) [@gyan](https://www.ruby-forum.com/u/gyan)\
**Post date:** [May 22, 2010, 7:57am UTC](https://www.ruby-forum.com/t/basic-question/189025/1 "2010-05-22T07:57:29Z")

</div>

Hello,

I’m new to Nginx and I have a basic problem. In short my “index.htm”  
isn’t dynamically loading on any sub-directories other than root.

For example, “[http://www.mydomain.com/](http://www.mydomain.com/)” will load the index.htm page  
just fine. However, “[http://www.mydomain.com/subdirectory/](http://www.mydomain.com/subdirectory/)” will not  
load  
the associated index.htm. I have to manually specify “…/index.htm”  
within the URL for the page to load. This can’t be right/normal.

My nginx.conf has this within the server declaration:

```
      location / {
        root /var/www/localhost/htdocs;
  index index.html index.htm;
  allow all;
      }

location ~* ^.+\.(jpg|jpeg|gif)$ {
  root /var/www/localhost/htdocs;
  access_log off;
  expires 30d;
}

```

What am I missing? This has become a show-stopper for my project so  
your help is _very_ much appreciated!

Thank you!

- Gyan

Posted at Nginx Forum:

> **[Basic question...](https://forum.nginx.org/read.php?2,89024,89024#msg-89024)**
>
> Hello, I'm new to Nginx and I have a basic problem. In short my "index.htm" isn't dynamically loading on any sub-directories other than root. For example, "http://www.mydomain.com/" will load the index.htm page just fine. However,...

---

<div class="post-metadata">

**Author:** ![gyan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/838e76/32.png) [@gyan](https://www.ruby-forum.com/u/gyan)\
**Post date:** [May 22, 2010, 8:05am UTC](https://www.ruby-forum.com/t/basic-question/189025/2 "2010-05-22T08:05:07Z")

</div>

On Sat, May 22, 2010 at 01:56:23AM -0400, gyan wrote:

> ```
> root /var/www/localhost/htdocs;
> 
> ```
> 
> What am I missing? This has become a show-stopper for my project so your help is _very_ much appreciated!  
> Do you have other locations ?

–  
Igor S.

> **[Igor Sysoev](http://sysoev.ru/en/)**

---

<div class="post-metadata">

**Author:** ![gyan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/838e76/32.png) [@gyan](https://www.ruby-forum.com/u/gyan)\
**Post date:** [May 22, 2010, 7:31pm UTC](https://www.ruby-forum.com/t/basic-question/189025/3 "2010-05-22T19:31:42Z")

</div>

Perhaps placing the root and index directives one level higher (i.e.  
within the server block) instead of at location / would be better.  
Just customise the individual locations within the server.

server {  
…  
…  
root Â /var/www/localhost/htdocs;  
index Â index.html index.htm;

```
location / {
    allow all;
}

...
...

```

}

Ray.

---

<div class="post-metadata">

**Author:** ![gyan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/838e76/32.png) [@gyan](https://www.ruby-forum.com/u/gyan)\
**Post date:** [May 22, 2010, 8:01pm UTC](https://www.ruby-forum.com/t/basic-question/189025/4 "2010-05-22T20:01:33Z")

</div>

No, those are it.

Posted at Nginx Forum:

> **[Re: Basic question...](https://forum.nginx.org/read.php?2,89024,89150#msg-89150)**
>
> Hello, I'm new to Nginx and I have a basic problem. In short my "index.htm" isn't dynamically loading on any sub-directories other than root. For example, "http://www.mydomain.com/" will load the index.htm page just fine. However,...

---

<div class="post-metadata">

**Author:** ![gyan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/838e76/32.png) [@gyan](https://www.ruby-forum.com/u/gyan)\
**Post date:** [May 22, 2010, 9:18pm UTC](https://www.ruby-forum.com/t/basic-question/189025/5 "2010-05-22T21:18:50Z")

</div>

Found the issue… My bad; mutliple conf files on sever…

Thanks guys for the help!

- Gyan

Posted at Nginx Forum:

> **[Re: Basic question...](https://forum.nginx.org/read.php?2,89024,89164#msg-89164)**
>
> Hello, I'm new to Nginx and I have a basic problem. In short my "index.htm" isn't dynamically loading on any sub-directories other than root. For example, "http://www.mydomain.com/" will load the index.htm page just fine. However,...

---

<div class="post-metadata">

**Author:** ![gyan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/838e76/32.png) [@gyan](https://www.ruby-forum.com/u/gyan)\
**Post date:** [May 22, 2010, 8:02pm UTC](https://www.ruby-forum.com/t/basic-question/189025/6 "2010-05-22T20:02:44Z")

</div>

Hmmm, tried this and same result.

Question. Is this normal behavior? I’m used to tomcat taking the index  
of any directory and using it as a default – I never expected Nginx to  
only use the root index and ignore all sub directories.

Thank you for your posts…

- Gyan

Posted at Nginx Forum:

> **[Re: Basic question...](https://forum.nginx.org/read.php?2,89024,89151#msg-89151)**
>
> Hello, I'm new to Nginx and I have a basic problem. In short my "index.htm" isn't dynamically loading on any sub-directories other than root. For example, "http://www.mydomain.com/" will load the index.htm page just fine. However,...
