问题原文
原帖链接 · MW. · CC BY-SA 4.0
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?
已采纳解答
原帖链接 · MrWhite · CC BY-SA 4.0
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:
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
