Apache | Installing Content | Adding MIME Types (AddType)
Files published through a web server are not limited to text files or HTML files. A web server can handle many types of files, including images and videos. For a file requested by a client, the WWW server returns the file contents to the client according to what type of file was requested. The client then processes the received data using an appropriate display method.
The default combinations of MIME types and extensions are registered in the mime.types file. This file name and installation directory are configured by TypesConfig.
Search for TypesConfig in the httpd.conf file, and you should find content like the following.
<IfModule mime_module>
#
# TypesConfig points to the file containing the list of mappings from
# filename extension to MIME-type.
#
TypesConfig conf/mime.types
... omitted ...
</IfModule>
Because it is specified as a relative path, it is relative to ServerRoot, so the actual file becomes ${SRVROOT}\conf\mime.types.
C:\apache\Apache24\conf>dir
C 드라이브의 볼륨에는 이름이 없습니다.
볼륨 일련 번호: XXXX-XXXX
C:\apache\Apache24\conf 디렉터리
2019-11-26 오후 10:39 <DIR> .
2019-11-26 오후 10:39 <DIR> ..
2019-08-09 오후 11:50 1,820 charset.conv
2019-11-26 오후 10:39 <DIR> extra
2019-12-01 오후 11:41 20,686 httpd.conf
2019-08-09 오후 11:50 13,449 magic
2019-08-09 오후 11:50 62,702 mime.types <<<<<<<<<<<<<< 여기 있다.
2019-05-28 오후 10:12 11,259 openssl.cnf
2019-11-26 오후 10:39 <DIR> original
5개 파일 109,916 바이트
4개 디렉터리 456,097,648,640 바이트 남음
C:\apache\Apache24\conf>
mime.types is a text file. If you open it in a text editor and extract a small part, it looks like this.
# MIME type (lowercased) Extensions
# ============================================ ==========
application/json json
text/css css
text/csv csv
text/html html htm
text/plain txt text conf def list log in
Extensions corresponding to MIME types are registered. For example, files with the .html and .htm extensions have the MIME type text/html, and files with the .txt and .log extensions have the MIME type text/plain.
Adding a MIME type
You can additionally register MIME types for extensions other than those already registered. In this case, instead of adding them to mime.types, it is recommended to write them in httpd.conf using AddType.
AddType MIME type extension
Specify the MIME type and extension as a pair.
Search for AddType in the httpd.conf file, and you should find content like the following.
<IfModule mime_module>
... omitted...
#
# AddType allows you to add to or override the MIME configuration
# file specified in TypesConfig for specific file types.
#
#AddType application/x-gzip .tgz
#
# AddEncoding allows you to have certain browsers uncompress
# information on the fly. Note: Not all browsers support this.
#
#AddEncoding x-compress .Z
#AddEncoding x-gzip .gz .tgz
#
# If the AddEncoding directives above are commented-out, then you
# probably should define those extensions to indicate media types:
#
AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz
... omitted...
</IfModule>
For example, to configure MIME types for PHP files, .php and .phps, write the following.
<IfModule mime_module>
... omitted ...
#
# AddType allows you to add to or override the MIME configuration
# file specified in TypesConfig for specific file types.
#
#AddType application/x-gzip .tgz
#
# AddEncoding allows you to have certain browsers uncompress
# information on the fly. Note: Not all browsers support this.
#
#AddEncoding x-compress .Z
#AddEncoding x-gzip .gz .tgz
#
# If the AddEncoding directives above are commented-out, then you
# probably should define those extensions to indicate media types:
#
AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
... omitted ...
</IfModule>