# Do nginx do not auto differentiate the file name and directory name in the url?

**URL:** <https://www.ruby-forum.com/t/do-nginx-do-not-auto-differentiate-the-file-name-and-directory-name-in-the-url/184255>\
**Category:** NGINX\
**Created:** [February 27, 2010, 10:33am UTC](https://www.ruby-forum.com/t/do-nginx-do-not-auto-differentiate-the-file-name-and-directory-name-in-the-url/184255 "2010-02-27T10:33:19Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![ultrawind](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/73ab20/32.png) [@ultrawind](https://www.ruby-forum.com/u/ultrawind)\
**Post date:** [February 27, 2010, 10:33am UTC](https://www.ruby-forum.com/t/do-nginx-do-not-auto-differentiate-the-file-name-and-directory-name-in-the-url/184255/1 "2010-02-27T10:33:19Z")

</div>

I 'm sorry for my bad english, i hope you can help me.

I already setup the nginx and php.

while i visit “[http://localhost/myweb](http://localhost/myweb)”

the server return “Internet Explorer cannot display the webpage”

while i visit “[http://localhost/myweb/](http://localhost/myweb/)”

then i can visit naturaly.

how can i solve this problem?

Should i config the nginx.conf file ?

Posted at Nginx Forum:

> **[Do nginx do not auto differentiate the file name and directory name in the url?](https://forum.nginx.org/read.php?2,57890,57890#msg-57890)**
>
> I 'm sorry for my bad english, i hope you can help me. I already setup the nginx and php. while i visit "http://localhost/myweb" the server return "Internet Explorer cannot display the webpage" while i visit "http:/

---

<div class="post-metadata">

**Author:** ![ultrawind](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/73ab20/32.png) [@ultrawind](https://www.ruby-forum.com/u/ultrawind)\
**Post date:** [February 27, 2010, 11:46am UTC](https://www.ruby-forum.com/t/do-nginx-do-not-auto-differentiate-the-file-name-and-directory-name-in-the-url/184255/2 "2010-02-27T11:46:29Z")

</div>

On Sat, Feb 27, 2010 at 4:32 PM, ultrawind [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> then i can visit naturaly.
> 
> how can i solve this problem?
> 
> Should i config the nginx.conf file ?
> 
> Posted at Nginx Forum: [http://forum.nginx.org/read.php?2,57890,57890#msg-57890](http://forum.nginx.org/read.php?2,57890,57890#msg-57890)

please post your config

–  
O\< ascii ribbon campaign - stop html mail - [www.asciiribbon.org](http://www.asciiribbon.org)

---

<div class="post-metadata">

**Author:** ![ultrawind](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/73ab20/32.png) [@ultrawind](https://www.ruby-forum.com/u/ultrawind)\
**Post date:** [February 28, 2010, 8:39am UTC](https://www.ruby-forum.com/t/do-nginx-do-not-auto-differentiate-the-file-name-and-directory-name-in-the-url/184255/3 "2010-02-28T08:39:59Z")

</div>

Hi

You mean something like Apache’s mod\_dir’s DirectorySlash. I’ve just  
tried and it works atomatically for me on a clean nginx install, no need  
to configure anything.

When you visit localhost/myweb, besides IE giving an error, does the  
address turn to “myweb/” or not? Is nginx correctly issuing the HTTP 301  
redirect? Can you try with Firefox and the LiveHTTPHeaders extension and  
verify this?

Could you post your config?

Regards

El 27/02/2010, a las 10:32, ultrawind  
escribió:

> then i can visit naturaly.  
> nginx mailing list  
> [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
> [mailman.nginx.org archive](http://nginx.org/mailman/listinfo/nginx)

–  
Vicente A. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) | [http://www.bisente.com](http://www.bisente.com)

---

<div class="post-metadata">

**Author:** ![ultrawind](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/73ab20/32.png) [@ultrawind](https://www.ruby-forum.com/u/ultrawind)\
**Post date:** [March 1, 2010, 7:49am UTC](https://www.ruby-forum.com/t/do-nginx-do-not-auto-differentiate-the-file-name-and-directory-name-in-the-url/184255/4 "2010-03-01T07:49:56Z")

</div>

Hi

> 192.168.1.19 - - [01/Mar/2010:10:42:33 +0800] “GET /myweb HTTP/1.1” 301 178 “-” “Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trid  
> ent/4.0; .NET CLR 2.0.50727; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022)”

nginx seems to be issuing the 301 HTTP redirect redirect, notice the 301  
after the GET.

What’s your URL after you go to [http://domain/myweb](http://domain/myweb) and get the error?  
According to that log you’ve received a redirect and it should have  
changed to [http://domain/myweb/](http://domain/myweb/). Does it show domain or localhost?  
You’re using localhost as the server\_name, I’m not sure if maybe nginx  
is using that domain to issue the Location on the redirect. If you’re  
testing this from a different machine than your server it will sure  
fail.

Please try with the LiveHTTPHeaders Firefox plugin and tell us what  
Location: are you being redirected to on the HTTP 301.

Regards

–  
Vicente A. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) | [http://www.bisente.com](http://www.bisente.com)

---

<div class="post-metadata">

**Author:** ![ultrawind](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/73ab20/32.png) [@ultrawind](https://www.ruby-forum.com/u/ultrawind)\
**Post date:** [March 1, 2010, 3:52am UTC](https://www.ruby-forum.com/t/do-nginx-do-not-auto-differentiate-the-file-name-and-directory-name-in-the-url/184255/5 "2010-03-01T03:52:54Z")

</div>

dear all, i use Firefox to visit “[http://localhost/myweb](http://localhost/myweb)” , is also do  
not work.  
here is my nginx.conf  
user daemon;  
worker\_processes 2;

#error\_log logs/error.log;  
#error\_log logs/error.log notice;  
error\_log logs/error.log info;

#pid logs/nginx.pid;

events {  
worker\_connections 1024;  
}

http {  
include mime.types;  
default\_type application/octet-stream;  
server\_tokens off;

```
#access_log logs/access.log main;

sendfile on;
#tcp_nopush on;

keepalive_timeout 65;

#gzip on;

server {
    listen 80;
    server_name localhost;

    #charset koi8-r;

    #access_log logs/host.access.log main;

    location / {
        root /home/httpd/html;
        index index.html index.htm index.php;
    }

    #error_page 404 /404.html;

    # redirect server error pages to the static page /50x.html
    #
    error_page 500 502 503 504 /50x.html;
    location = /50x.html {
        root html;
    }

    # pass the PHP scripts to FastCGI server listening on 

```

127.0.0.1:9000

```
    location ~ \.php$ {
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME 

```

/home/httpd/html/$fastcgi\_script\_name;  
include fastcgi\_params;  
}

```
}

```

}

here is the access.log record result  
fail  
192.168.1.19 - - [01/Mar/2010:10:42:33 +0800] “GET /myweb HTTP/1.1” 301  
178 “-” “Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trid  
ent/4.0; .NET CLR 2.0.50727; .NET CLR 3.0.04506.648; .NET CLR  
3.5.21022)”  
success  
192.168.1.19 - - [01/Mar/2010:10:44:18 +0800] “GET /myweb/ HTTP/1.1” 200  
45696 “-” “Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1;  
Trident/4.0; .NET CLR 2.0.50727; .NET CLR 3.0.04506.648; .NET CLR  
3.5.21022)”

Posted at Nginx Forum:

> **[Re: Do nginx do not auto differentiate the file name and directory name in...](https://forum.nginx.org/read.php?2,57890,58466#msg-58466)**
>
> I 'm sorry for my bad english, i hope you can help me. I already setup the nginx and php. while i visit "http://localhost/myweb" the server return "Internet Explorer cannot display the webpage" while i visit "http:/

---

<div class="post-metadata">

**Author:** ![ultrawind](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/73ab20/32.png) [@ultrawind](https://www.ruby-forum.com/u/ultrawind)\
**Post date:** [March 2, 2010, 3:56pm UTC](https://www.ruby-forum.com/t/do-nginx-do-not-auto-differentiate-the-file-name-and-directory-name-in-the-url/184255/6 "2010-03-02T15:56:50Z")

</div>

On Mon, Mar 01, 2010 at 09:29:35PM -0500, ultrawind wrote:

> hello,Vicente A.,  
> thank you for your helping.I found the point by the LiveHTTPHeaders Firefox plugin .  
> i set the server\_name localhost to 192.168.1.124;Then it’s work now.

You should either set “server\_name\_in\_redirect off” or set server\_name  
to the requested domain name.

> ## Keep-Alive: 115
> 
> Posted at Nginx Forum: [http://forum.nginx.org/read.php?2,57890,58862#msg-58862](http://forum.nginx.org/read.php?2,57890,58862#msg-58862)
> 
> * * *
> 
> nginx mailing list  
> [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
> [mailman.nginx.org archive](http://nginx.org/mailman/listinfo/nginx)

–  
Igor S.

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

---

<div class="post-metadata">

**Author:** ![ultrawind](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/73ab20/32.png) [@ultrawind](https://www.ruby-forum.com/u/ultrawind)\
**Post date:** [March 4, 2010, 9:04am UTC](https://www.ruby-forum.com/t/do-nginx-do-not-auto-differentiate-the-file-name-and-directory-name-in-the-url/184255/7 "2010-03-04T09:04:10Z")

</div>

i got it, thank you.

Posted at Nginx Forum:

> **[Re: Do nginx do not auto differentiate the file name and directory name in...](https://forum.nginx.org/read.php?2,57890,59829#msg-59829)**
>
> I 'm sorry for my bad english, i hope you can help me. I already setup the nginx and php. while i visit "http://localhost/myweb" the server return "Internet Explorer cannot display the webpage" while i visit "http:/

---

<div class="post-metadata">

**Author:** ![ultrawind](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/73ab20/32.png) [@ultrawind](https://www.ruby-forum.com/u/ultrawind)\
**Post date:** [March 2, 2010, 3:29am UTC](https://www.ruby-forum.com/t/do-nginx-do-not-auto-differentiate-the-file-name-and-directory-name-in-the-url/184255/8 "2010-03-02T03:29:58Z")

</div>

hello,Vicente A.,  
thank you for your helping.I found the point by the LiveHTTPHeaders  
Firefox plugin .  
i set the server\_name localhost to 192.168.1.124;Then it’s work now.

this is the result:  
[http://192.168.1.124/myweb](http://192.168.1.124/myweb)

GET /homekoo.com HTTP/1.1  
Host: 192.168.1.124  
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN; rv:1.9.2)  
Gecko/20100115 Firefox/3.6  
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,_/_;q=0.8  
Accept-Language: zh-cn,zh;q=0.5  
Accept-Encoding: gzip,deflate  
Accept-Charset: GB2312,utf-8;q=0.7,\*;q=0.7  
Keep-Alive: 115  
Connection: keep-alive  
Cookie: visit\_level=2; db\_=idsYt7hyLPjGct%2Bh8MfNpErRnk2t9T9D6Vf4iJ4;  
others=2NkY5OwkK6n%2FSYfB8Ao; rtime=4; ltime=1267496256399;  
cnzz\_eid=39895488-1264743989-;  
\_\_utma=81186391.1499015929.1265772641.1267411366.1267496256.3;  
\_\_utmz=81186391.1265772641.1.1.utmccn=(direct)|utmcsr=(direct)|utmcmd=(none);  
Hm\_lvt\_7cb1f2f2baf6ab2ae929ad8cb88d6210=1265772641278; cnzz\_a485651=0;  
sin485651=; cnzz\_a977997=0; sin977997=; cnzz\_a1366560=0; sin1366560=;  
\_\_utmb=81186391; \_\_utmc=81186391; \_SID=6e46d49d85cf0da3b88eac61b6a3edd1

## HTTP/1.1 301 Moved Permanently Server: nginx Date: Tue, 02 Mar 2010 02:16:21 GMT Content-Type: text/html Content-Length: 178 Location: [http://localhost/myweb/](http://localhost/myweb/) Connection: keep-alive

Posted at Nginx Forum:  
[http://forum.nginx.org/read.php?2,57890,58862#msg-58862](http://forum.nginx.org/read.php?2,57890,58862#msg-58862)
