Matching on content-type in htaccess

I know I can use FilesMatch ".html$" like this:

<FilesMatch ".html$">
    Header set Pragma "public"
    Header set Cache-Control "public, must-revalidate, proxy-revalidate"
</FilesMatch>

But this won’t help if the html is delivered as a SEO friendly URL (like wordpress does), right?

Read More

I there a way to match on content-type equals text/html?

Related posts

Leave a Reply

1 comment

  1. If you’re on Apache 2.4.10 or later, you can use expr= as

    Header set Pragma "public" "expr=%{CONTENT_TYPE} =~ m#text/html#"
    Header set Cache-Control "public, must-revalidate, proxy-revalidate" "expr=%{CONTENT_TYPE} =~ m#text/html#"
    

    See the documentation and examples on mod_headers and expr.