21

写真があり、そのヘッダーを最大に追加したい、変更して写真を投稿できるプロフィール写真がある、投稿写真にのみヘッダーを追加したいが、プロフィール写真にはヘッダーを追加したくない、どうすれば管理できるかわからないこれ。ありがとう、これは私の設定です、

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";
}
4

1 に答える 1

34

現在、これを解決するには2 つのオプションがあります。

オプション1:

重複した場所: NGINX は最適な一致を探します。(少し性能が良い)

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;
    .
    .
    .
}

オプション 2:

ネストされた場所: 内側の場所ブロックの拡張子によってフィルター処理されます

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)$ {
        ...

    }
}
于 2013-06-06T00:08:06.430 に答える