0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

拡張子が無いファイルにContent-Type(MIMEタイプ)指定する方法《.htaccess》

Last updated at Posted at 2025-09-08

はじめに

.htaccess を使って、拡張子が無いファイルContent-Type(MIMEタイプ) を指定する方法をまとめました。

拡張子が無いファイルとは?

【拡張子あり】samplefile.txt
【拡張子なし】samplefile

ファイル名(例:samplefile)の後ろに拡張子が書かれていないファイルのこと。

.htaccess 書き方の例

拡張子が無いファイルにContent-Type(MIMEタイプ)指定

.htaccess
Header set Content-Type "▲▲▲▲▲" "expr=%{REQUEST_URI} == '/▼▼▼▼▼'"

▲▲▲▲▲ : Content-Type(MIMEタイプ)
▼▼▼▼▼ : ファイルのURI(ファイル名)

.htaccess 実際の使用例

/.well-known/
という名前のフォルダに入っている
traffic-advice
という名前のファイルに
application/trafficadvice+json
というContent-Type(MIMEタイプ)を指定する場合

.htaccess
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)

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?