0

I know how to process URIs that match a certain pattern.

Example

The following configuration will add an Cache-Control http-header to all files ending with .css or .js:

location ~* \.(css|js)$ {
  add_header Cache-Control "public, max-age=31536000, immutable" always;
}

Question

How can I process all URIs without extension?

Something like www.domain.tld/my-article.

(I use nginx as an reverse-proxy and I add the extension .html in the .htaccess.)

Sr. Schneider
  • 185
  • 2
  • 6

1 Answers1

2

The usual way is:

location / {
    # Everything else
}

location ~* \.(?:css|js)$ {
    add_header Cache-Control "public, max-age=31536000, immutable" always;
}

nginx location directive documentation explains in detail how nginx evaluates different location blocks.

Tero Kilkanen
  • 36,796
  • 3
  • 41
  • 63