웹서버/Apache

[Tips] MIME 타입 추가

투칼론 2016. 6. 14. 01:23
반응형

Apache에서 MIME 타입을 추가하는 방법은 2가지가 있다.

 

mime.types 파일에 설정하고자 하는 MIME 타입을 추가하는 방법과 'AddType' 지시자를 사용하여 추가하는 방법이 있다. 아래는 한글과컴퓨터의 .hwpx 확장자 파일에 대해 MIME 타입 추가하는 예시이다.

 

1. mime.types 파일에 추가하는 방법

 

mime.types 파일에 추가하고자 하는 MIME 타입과 파일 확장자 정보를 추가한다. 이 방법은 Apache 업그레이드 시에 mime.types 파일이 변경될 수 있어 권장하지는 않는다.

# MIME type (lowercased)			            Extensions
# ============================================	==========
......
application/vnd.hancom.hwpx                     hwpx
......

 

참고로, mime.types 파일 위치는 httpd.conf 파일의 TypesConfig 지시자에 지정되어 있다. 기본은 conf/mime.types 파일이다.

< httpd.conf 파일 내용 >

<IfModule mime_module>
    #
    # TypesConfig points to the file containing the list of mappings from
    # filename extension to MIME-type.
    #
    TypesConfig conf/mime.types
    ......

</ IfModule>

 

2. httpd.conf의 mime 모듈에 AddType 지시자 설정하는 방법 (권장 방법)

<IfModule mime_module>
    #
    # TypesConfig points to the file containing the list of mappings from
    # filename extension to MIME-type.
    #
    TypesConfig conf/mime.types
    ......
    AddType application/vnd.hancom.hwpx   .hwpx
    ......

</ IfModule>

 

 

위의 작업 후에 Apache 웹서버를 재기동해야 한다.