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?
Best Answer
For non-200 OK responses you need to use the
always
condition:Note that
always
(as opposed toonsuccess
- the default) refers to the internal table of HTTP response headers, it doesn't necessarily mean that it is always set.Reference: