はじめに
.htaccess を使って、拡張子が無いファイルに Content-Type(MIMEタイプ) を指定する方法をまとめました。
拡張子が無いファイルとは?
【拡張子あり】samplefile.txt
【拡張子なし】samplefile
ファイル名(例:samplefile)の後ろに拡張子が書かれていないファイルのこと。
.htaccess 書き方の例
拡張子が無いファイルにContent-Type(MIMEタイプ)指定
Header set Content-Type "▲▲▲▲▲" "expr=%{REQUEST_URI} == '/▼▼▼▼▼'"
▲▲▲▲▲ : Content-Type(MIMEタイプ)
▼▼▼▼▼ : ファイルのURI(ファイル名)
.htaccess 実際の使用例
/.well-known/
という名前のフォルダに入っている
traffic-advice
という名前のファイルに
application/trafficadvice+json
というContent-Type(MIMEタイプ)を指定する場合
Header set Content-Type "application/trafficadvice+json;" "expr=%{REQUEST_URI} == '/.well-known/traffic-advice'"
使用例
/.well-known/traffic-advice
https://text.sakura.ne.jp/.well-known/traffic-advice
.htaccess 解説
Header set Content-Type
↳ Content-Type(MIMEタイプ)を指定
"application/trafficadvice+json;"
↳ Content-Type(MIMEタイプ)は『application/trafficadvice+json;』
"expr=%{REQUEST_URI} == '/.well-known/traffic-advice'"
↳ URIが『/.well-known/traffic-advice』の場合に適用
関連サイト
Chrome のプライベート プリフェッチ プロキシ|Chrome for Developers
https://developer.chrome.com/blog/private-prefetch-proxy?hl=ja
(text_sakura)