如何仅使用nginx将特定文件添加到特定文件中

我有图片,我想添加他们的标题为最大,我有个人资料的图片,可以更改和发布图片,我想添加标题只为后期图片,但不是个人资料图片,我不知道如何管理这个.谢谢,这是我的配置,

this is the path of posts,/post/name-of-the-picture.jpg

this is the path of users,/user/name-of-the-picture.jpg

我只想添加标题来发布路径

location ~* \.(css|js|png|gif)${
   expires max;
   add_header Pragma public;
   add_header Cache-Control "public";
}

最佳答案
目前我们有两个选择来解决这个问题:

选项1:

Duplicated locations: NGINX looks for the best match. (a little better performance)

location /post/ {
    post config stuff;
    .
    .
    .
}    
location ~* ^/post/.*\.(css|js|png|gif)${
    post/files.(css|js|png|gif) config stuff;
    expires max;
    add_header Pragma public;
    add_header Cache-Control "public";
}
location /user/ {
    user folder config stuff;
    .
    .
    .
}    
location ~* ^/user/.*\.(css|js|png|gif)${
    user/files.(css|js|png|gif) config stuff;
    .
    .
    .
}

选项二:

Nested locations: Filtered by extension in the inner location blocks

location /post/{
    ...

    location ~* \.(css|js|png|gif)${
        expires max;
        add_header Pragma public;
        add_header Cache-Control "public";
    }
}
location /user/{
    ...

    location ~* \.(css|js|png|gif)${
        ...

    }
}

dawei

【声明】:淮南站长网内容转载自互联网,其相关言论仅代表作者个人观点绝非权威,不代表本站立场。如您发现内容存在版权问题,请提交相关链接至邮箱:bqsm@foxmail.com,我们将及时予以处理。