我无法将注意力集中在注释和编码方式上,例如在 html5 样板中的 .htaccess 文件中仅为 .html 设置标题。
大代码块的线索在于“mod_headers 无法匹配内容类型”(如 # 注释)。所以我徘徊1:为什么a中有一个' Header unset
' <FilesMatch>
,刚刚被宣布为不可能?
<IfModule mod_headers.c>
Header set Content-Security-Policy "script-src 'self'; object-src 'self'"
# `mod_headers` cannot match based on the content-type, however,
# the `Content-Security-Policy` response header should be send
# only for HTML documents and not for the other resources.
<FilesMatch "\.(appcache|atom|bbaw|bmp|crx|css|cur|eot|f4[abpv]|flv|geojson|gif|htc|ico|jpe?g|js|json(ld)?|m4[av]|manifest|map|mp4|oex|og[agv]|opus|otf|pdf|png|rdf|rss|safariextz|svgz?|swf|topojson|tt[cf]|txt|vcard|vcf|vtt|webapp|web[mp]|woff2?|xloc|xml|xpi)$">
Header unset Content-Security-Policy
</FilesMatch>
</IfModule>
我到处看了看,但只登陆了具有相同的,几乎是仪式使用的代码块的页面,没有进一步的解释。所以问题2:为什么像这样的简单声明是不可能的?:
<IfModule mod_headers.c>
# Content-Security-Policy for .html files
<FilesMatch "\.(html)$">
Header set Content-Security-Policy "script-src 'self'; object-src 'self'"
</FilesMatch>
# OR like this
<Files ~ "\.(html)$">
Header set Cache-Control "public, must-revalidate"
</Files>
</IfModule>