Score:1

Apache 2.4 .htaccess Set Headers for error pages

aw flag
MW.

I am setting some headers using .htaccess for a web page, f. e.:

<IfModule mod_headers.c>
Header set Strict-Transport-Security "max-age=31536000; includeSubDomains"
</IfModule>

This works fine for usual page access, but the headers are not used on error pages like 404 Not Found and 403 Forbidden.

Is there a way to set Headers for error pages using .htaccess?

Score:1
kz flag
Header set Strict-Transport-Security "max-age=31536000; includeSubDomains"

For non-200 OK responses you need to use the always condition:

Header always set Strict-Transport-Security "max-age=31536000; includeSubDomains"

Note that always (as opposed to onsuccess - the default) refers to the internal table of HTTP response headers, it doesn't necessarily mean that it is always set.

Reference:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.