만약 IfModule 이라는 태그를 언제 사용할 수 있는지 봅니다.

아래 설명을 찾았습니다.



출처 : http://httpd.apache.org/docs/2.0/mod/core.html

<IfModule> Directive

Description: Encloses directives that are processed conditional on the presence or absence of a specific module
Syntax: <IfModule [!]module-name> ... </IfModule>
Context: server config, virtual host, directory, .htaccess
Override: All
Status: Core
Module: core

The <IfModule test>...</IfModule> section is used to mark directives that are conditional on the presence of a specific module. The directives within an <IfModule> section are only processed if the test is true. If test is false, everything between the start and end markers is ignored.

The test in the <IfModule> section directive can be one of two forms:

  • module name
  • !module name

In the former case, the directives between the start and end markers are only processed if the module named module name is included in Apache -- either compiled in or dynamically loaded using LoadModule. The second format reverses the test, and only processes the directives if module name is not included.

The module name argument is the file name of the module, at the time it was compiled. For example, mod_rewrite.c. If a module consists of several source files, use the name of the file containing the string STANDARD20_MODULE_STUFF.

<IfModule> sections are nest-able, which can be used to implement simple multiple-module tests.

This section should only be used if you need to have one configuration file that works whether or not a specific module is available. In normal operation, directives need not be placed in <IfModule> sections.




위의 문구중 아래를 확인한다.
Context: server config, virtual host, directory, .htaccess

http://httpd.apache.org/docs/2.0/mod/directive-dict.html#Context

사용장소 (Context)

서버의 설정파일중 어느곳에서 지시어를 사용할 수 있는지 알려준다. 다음 값들을 쉼표로 구분한 목록이다:

주서버설정 (server config)
지시어를 서버 설정파일에서 (예를 들어, httpd.conf) 사용할 수 있으나, <VirtualHost><Directory>에서 사용할 수 없음을 뜻한다. 이 지시어는 .htaccess 파일에서도 사용할 수 없다.
가상호스트 (virtual host)
지시어를 서버 설정파일의 <VirtualHost> 안에서 사용할 수 있음을 뜻한다.
디렉토리 (directory)
지시어가 어떻게 Directory, Location, Files 섹션이 동작하나에 설명한 제약을 따르며, 서버 설정파일의 <Directory>, <Location>, <Files>에서 사용할 수 있음을 뜻한다.
.htaccess
지시어를 디렉토리 .htaccess 파일에서 사용할 수 있음을 뜻한다. 이 지시어는 현재 사용하는 overrides 값에 따라 무시될 수 있다.

지시어는 지정된 장소에서 사용할 수 있다. 다른 곳에서 사용하면 설정오류가 발생하고 서버는 부분에 대한 요청을 올바로 처리하지 못하거나 작동이, 예를 들어 시작조차도, 안될 수 있다.

지시어를 사용할 수 있는 장소는 열거한 장소를 모두 불린(boolean) OR한 결과이다. 즉, "server config, .htaccess"에서 가능하다는 지시어는 httpd.conf 파일과 .htaccess 파일에서는 사용할 수 있지만, <Directory><VirtualHost>에서는 사용할 수 없다.


directory는  <Directory>, <Location>, <Files> 를 의미한다.

 

IfModule은 <directory>, <location>, <files> 태그 안에서 사용된다.

 

 

 

Posted by '김용환'
,