0

たとえば、html5ボイラープレートの.htaccessファイルに.htmlのみのヘッダーを設定するために、コメントとコーディングの方法に頭を悩ませることはできません。

大きなコードブロックの手がかりは、「mod_headers がコンテンツ タイプに一致しない」という事実にあります (# がコメントしたように)。だから私はさまよいます 1:不可能であると発表されたばかりの に ' 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>
4

1 に答える 1