0

I want to have a location directive for the url "localhost/test/" in the nginx configuration.

I tried the following in the configuration file:

server {
listen 80;
server_name localhost;
location /test/ {
root /home/test;
index index.html index.htm
}

}

This always give me a 404 error. Then i tried this one

server {
listen 80;
server_name localhost;
location / {
root /home/test;
index index.html index.htm
}

}

It just works fine on url "localhost"

I can't understand why it throws a 404 error in the first case !!

4

1 回答 1

1

您的配置的一个明显问题是必须使用别名而不是 root

location /test/ {
    alias /home/test/;
}

因为,root 使 nginx 根据您的配置搜索 /home/test/test。

于 2013-07-30T10:22:23.983 回答