Nginx中的静态文件设置?

时间:2015-11-12 12:59:35

标签: nginx

我想要'www.mydomain.com/images/20151111/test.jpg'可以访问 而且我确信'test.jpg'确实存在。 但它显示404未找到。 这是我的nginx设置。

server {
    listen  80;
    server_name www.mydomain.com;
    index index.html
    root /home/googleimage;


    location / {
        uwsgi_pass  unix:///tmp/pic.sock;
        include     uwsgi_params;
    }

    location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
            {
                root /home/wechat;
                    expires      30d;
            }

    location /images/ {
        alias /home/images/;
    }

}

这个版本中的'test.jpg' /home/images/20151111/test.jpg

出了什么问题?

1 个答案:

答案 0 :(得分:1)

URI char *ptr[buflen]; for(x = 0; x < n; x++) { printf("ptr[x] is %s \n", ptr[x]); cmp_str3 = strcmp(ptr[x], "];"); cmp_str4 = strcmp(ptr[x], ");"); if(cmp_str3 == 0) { printf("Match1 \n"); strcpy(str1, ptr[x]); printf("Match2 \n"); ptr[x][1] = '\0'; printf("Match3 \n"); //printf("ptr[x+1] %c %d \n", ptr[x+1], ptr[x+1]); //printf("ptr[x+1][0] %c %d \n", ptr[x+1][0], ptr[x+1][0]); ptr[x+1] = malloc(strlen("foo") + 1); ptr[x+1][0] = str1[1]; printf("Match4 \n"); ptr[x+1][1] = '\0'; printf("Match5 \n"); n++; } if(cmp_str4 == 0) { } } cmp_str3 = 0; cmp_str4 = 0; memset(str1, 0, 15); memset(str2, 0, 15); 首先与您的/images/20151111/test.jpg匹配,因为它优先。要使regex location优先写入为:

prefix location

请参阅this document了解location ^~ /images/ { alias /home/images/; } 语法和用法。