익명 사용자
로그인하지 않음
토론
기여
계정 만들기
로그인
IT 위키
검색
Apache AddType
편집하기
IT 위키
이름공간
문서
토론
더 보기
더 보기
문서 행위
읽기
편집
원본 편집
역사
경고:
로그인하지 않았습니다. 편집을 하면 IP 주소가 공개되게 됩니다.
로그인
하거나
계정을 생성하면
편집자가 사용자 이름으로 기록되고, 다른 장점도 있습니다.
스팸 방지 검사입니다. 이것을 입력하지
마세요
!
The '''AddType''' directive in Apache HTTP Server is used to define or change the MIME (Multipurpose Internet Mail Extensions) type for specific file extensions. MIME types tell the browser how to handle files received from the server, such as rendering HTML, displaying images, or executing scripts. Setting the correct MIME type is essential for the server to communicate file handling instructions to the client. ==Purpose of AddType== The '''AddType''' directive helps in setting the MIME type for various file extensions. This can be useful for: *Ensuring that web browsers interpret files correctly, such as displaying HTML or running JavaScript. *Supporting custom file types, which may not have a predefined MIME type. *Overriding default MIME types for specific file extensions to meet specific handling requirements. ==Syntax of AddType== The syntax for the `AddType` directive is as follows: AddType MIME-type file-extension [file-extension] ... *'''MIME-type''': The MIME type to associate with the file extension (e.g., `text/html`, `image/png`). *'''file-extension''': The file extension to apply the MIME type to (e.g., `.html`, `.png`). ==Examples of AddType Usage== ===Example 1: Setting HTML MIME Type=== To set `.html` and `.htm` files to be served as HTML: AddType text/html .html .htm This instructs the server to treat files with the `.html` and `.htm` extensions as HTML content. ===Example 2: Adding MIME Type for JavaScript=== To ensure `.js` files are treated as JavaScript: AddType application/javascript .js This directive helps browsers recognize and execute `.js` files correctly as JavaScript. ===Example 3: Custom MIME Type for Audio=== To add support for custom audio file extensions, such as `.myaudio`: AddType audio/mpeg .myaudio This associates the custom `.myaudio` extension with the `audio/mpeg` MIME type, allowing browsers to treat it as an audio file. ==Security Considerations== While setting MIME types correctly can enhance functionality, it is important to consider security: *'''Avoid Incorrect MIME Types for Executable Files''': Ensure that potentially harmful files are not mistakenly served with an executable MIME type. *'''Use Proper MIME Types for Scripts''': Incorrectly setting MIME types for scripts (e.g., `application/javascript` for `.js` files) can cause cross-site scripting vulnerabilities if not managed properly. *'''Restrict Untrusted File Types''': Be cautious when defining new MIME types for unknown file extensions, especially in environments where users can upload files. ==Related Concepts== Understanding the `AddType` directive involves familiarity with other Apache directives and web concepts: *'''DefaultType''': Sets the MIME type for files with unknown extensions if not explicitly defined by `AddType`. *'''AddHandler''': Associates specific file types with particular server actions, such as treating files as PHP scripts. *'''MIME Types''': The broader concept of file types used by browsers to handle content appropriately. *'''.htaccess''': `AddType` can be configured within `.htaccess` files for per-directory MIME type management. ==See Also== *[[Apache Configuration]] *[[MIME Types]] *[[AddHandler]] *[[DefaultType]] *[[.htaccess]] *[[Web Security]]
요약:
IT 위키에서의 모든 기여는 크리에이티브 커먼즈 저작자표시-비영리-동일조건변경허락 라이선스로 배포된다는 점을 유의해 주세요(자세한 내용에 대해서는
IT 위키:저작권
문서를 읽어주세요). 만약 여기에 동의하지 않는다면 문서를 저장하지 말아 주세요.
또한, 직접 작성했거나 퍼블릭 도메인과 같은 자유 문서에서 가져왔다는 것을 보증해야 합니다.
저작권이 있는 내용을 허가 없이 저장하지 마세요!
취소
편집 도움말
(새 창에서 열림)
둘러보기
둘러보기
대문
최근 바뀜
광고
위키 도구
위키 도구
특수 문서 목록
문서 도구
문서 도구
사용자 문서 도구
더 보기
여기를 가리키는 문서
가리키는 글의 최근 바뀜
문서 정보
문서 기록