How to set a specific header in a single folder with Nginx?

前端 未结 1 2020
长发绾君心
长发绾君心 2021-01-15 06:57

I want to keep the exact same settings as below in all folders, except for one. In the folder /wp-admin the setting add_header Cache-Control \"no-store\"; shoul

相关标签:
1条回答
  • 2021-01-15 07:49

    Any location block that processes PHP files needs to contain all of the fastcgi parameters and directives. See this document on request processing.

    I have not tested this, but you should be able to use a map directive to select the appropriate value for the add_header statement.

    For example:

    map $request_uri $cc {
        ~^/wp-admin  "no-store";
        default      "public";
    }
    
    server {
        ...
        location ~ \.php$ {
            add_header Cache-Control $cc;
            ...
        }
    }
    

    See this document for details.

    0 讨论(0)
提交回复
热议问题