워드프레스 htaccess rewriterule 파일 및 디렉토리 속성자 / flags

워드프레스 htaccess rewriterule 파일 및 디렉토리 속성자 / flags

워드프레스에서 사용하는 htaccess mod_rewrite의 rewriterule 파일 및 디렉토리 속성자, datatype 및 Flag 리다이렉트들을 공부할 겸 정리합니다.

htaccess rewriterule 파일 및 디렉토리 속성자 datatype 및 Flag 리다이렉트 / flags htaccess-rewriterule-file-directory-file-attributes-flags_1629_600

1. 파일 및 디렉토리 속성 (지시자)


 

  • -f    (파일이다) : 테스트스트링을 패스로 취급하고 존재하고 있는 지 테스트한 후 (없으면) 정규 파일임 ( Treats the TestString as a pathname and tests whether or not it exists, and is a regular file ).

  • -d   (디렉토리이다) 테스트스트링을 패스(경로)로 간주하고 그 존재 여부를 테스트한 후 디렉토리임 (Treats the TestString as a pathname and tests whether or not it exists, and is a directory)

  • -H    (심볼릭 링크, bash 규약) : ‘-I’ 참조 (See -l). 심볼릭 링크는 하드 링크와는 차이가 있다. 하드 링크는 다른 볼륨이나 파일 시스템 상의 경로를 연결하지 않지만 심볼릭 링크는 링크와 대상이 존재하는 볼륨의 어느 파일이나 디렉터리라도 가리킬 수 있다. 하드 링크는 무조건 기존의 파일만을 가리키는 반면 심볼릭 링크는 어느 것을 가리키지 않는 임의의 경로를 포함할 수도 있다.

  • -l    (심볼릭 링크) : 테스트스트링을 패스로 간주하여 그 존재 여부를 테스트하며, 하나의 심볼릭 링크임. 
    Treats the TestString as a pathname and tests whether or not it exists, and is a symbolic link. May also use the bash convention of -L or -h if there’s a possibility of confusion such as when using the -lt or -le tests.

  • -L   (is symbolic link, bash convention) : 심볼링 링크, bash 규약

이와 같은 모든 테스트들은 앞에(접두사 같이) 느낌표(‘!’)를 붙이면 부정(반대)의 의미를 갖는다.

[adsense_mo1]

All of these tests can also be prefixed by an exclamation mark (‘!’) to negate their meaning.


htaccess rewriterule 파일 및 디렉토리 속성자 워드프레스/ flags htaccess-rewriterule-file-directory-file-attributes-flags

 

2. Flags (신호명령) :  ⇒ 번역상의 오류가 있을 수 있으므로 영어 원문을 첨부합니다.


플래그와 구문 규칙 함수 (Flag and syntax Function) ;  A | word 형식에서 플래그로 쓰일때는 앞에 나오는 문자를 [A] 형식으로 사용. 기억하려면 뒤에 나오는 단어로 암기하시면 도움이 될 듯 합니다.

  • B    →   변형을 적용하기 전에 비 알파벳-숫자 문자로 부터 회피 (B Escape non-alphanumeric characters before applying the transformation).

  • C | chain    →   이 룰은 다음에 오는 규칙을 종속시킨다. 만일 이 규칙이 실패하면, 이 룰에 종속된 다음 규칙은 건너 뛴다. ( is chained to the following rule. If the rule fails, the rule(s) chained to it will be skipped).

  • CO=NAME:VAL | cookie   →   클라이언트 브라우저에 쿠키를 설정한다. 완전한 구문(Full syntax)은 다음의 형식을 따른다. → CO=NAME:VAL:domain[:lifetime[:path[:secure[:httponly]]]]

  • DPI | discardpath → 재작성된 URI의 경로정보(PATH_INFO)를 버린다. → Causes the PATH_INFO portion of the rewritten URI to be discarded.

  • END  →   재작성 과정을 즉시 중지시키며, 더 이상 어떤 규칙도 적용하지 않는다. 또한 디렉토리 단위에 있는 rewrite 규칙 및 .htaccess 문장을 더이상 수행하지 않는다.  → Stop the rewriting process immediately and don’t apply any more rules. Also prevents further execution of rewrite rules in per-directory and .htaccess context.

  • E=[!]VAR[:VAL] | env  →   환경 변수 VAR를 VAL 값이 제공되었다면 그로 설정한다. !VAR 형식은 환경변수 VAR를 설정 해제한다. → Causes an environment variable VAR to be set (to the value VAL if provided). The form !VAR causes the environment variable VAR to be unset.

  • F | forbidden  →   클라이언트 브라우저를 403 접근 금지(FORBIDDEN) 시킨다. → Returns a 403 FORBIDDEN response to the client browser.

  • G | gone → 클라이언트 브라우저에 영구적으로 사용 금지(410 GONE)하게 한다.→  Returns a 410 GONE response to the client browser.

  • H=Content-handler | Handler →  URI를 처리를 위해 정해진 Content-handler로 보낸다. →  Causes the resulting URI to be sent to the specified Content-handler for processing.

  • L | last  →   재작성 과정을 즉시 중지시키며 어떠한 다른 규칙도 적용하지 않는다.  특별히 디렉토리 단위별 규칙과 .htaccess 문장, 그리고 END 플래그를 참조할 필요가 있다. → Stop the rewriting process immediately and don’t apply any more rules. Especially note caveats for per-directory and .htaccess context (see also the END flag).

  • N | next  →   해당 ruleset의 결과를 사용하여 재작성 과정을 다시 첫번째 규칙, 출발점까지 보낸다.  → Re-run the rewriting process, starting again with the first rule, using the result of the ruleset so far as a starting point.

  • NC | nocase → 대소 문자 패턴 비교를 한다.   →  Makes the pattern comparison case-insensitive.

  • NE | noescape → mod_rewrite로 하여금 해당 rewrite의 결과에서 특수 문자로부터 회피(Escaping)시키는 16진수를 적용하지 못하도록 막는다. → Prevent mod_rewrite from applying hexcode escaping of special characters in the result of the rewrite.

  • NS | nosubreq → 만일 현재의 요청이 하나의 어떤 내부 2차 요청이라면 규칙을 생략시킨다. → Causes a rule to be skipped if the current request is an internal sub-request.

  • P | proxy→ 대체 URL을 프록시 요청으로서 내부적으로 보내어지도록 강제한다. →  Force the substitution URL to be internally sent as a proxy request.

  • PT | passthrough → 결과 URL을 URL mapping 엔진으로 전달되도록 강제화 한다. 여기서 URL mapping 엔진은 예를 들어 Alias 또는 Redirect와 같은 다른 URI-to-filename 번역자를 처리하는 엔진을 말한다.  → Forces the resulting URI to be passed back to the URL mapping engine for processing of other URI-to-filename translators, such as Alias or Redirect.

  • QSA | qsappend  →  원래 요청 URL으로부터 온 모든 쿼리 요청을 재작성 목타겟에서 만들어지는 쿼리 스트링으로 첨부시킨다.  →  Appends any query string from the original request URL to any query string created in the rewrite target.

  • QSD | qsdiscard  → 들어오는 URI에 첨부된 모든 쿼리스트링을 버린다 . →  Discard any query string attached to the incoming URI.

  • R[=code] | redirect → 외부 리다이렉트를 강제화한다. 명시된 HTTP 상태 코드를 선택적으로 포함한다. →  Forces an external redirect, optionally with the specified HTTP status code.

  • S=num | skip  →  만일 현재의 규칙이 후행하는 규칙과 일치한다면 재작성 엔진으로 하여금 num 숫자만큼을 생략하게(건너 뛰도록) 한다. → Tells the rewriting engine to skip the next num rules if the current rule matches.

  • T=MIME-type | type  →  목적 파일의 MIME-type을 명시된 타잎으로 강제화한다.  →  Force the MIME-type of the target file to be the specified type.

워드프레스 htaccess rewriterule 파일 및 디렉토리 속성자 / flags htaccess-rewriterule-file-directory-file-attributes-flags_1632_600

이상으로 워드프레스 htaccess rewriterule 파일, datatype, 리다이렉트와 관련된 디렉토리 속성자(지시자?) 및 flags를 마치며, 추가 설명이나 보완 내용은 댓글로 달거나, 의견이 있으시면 달아주세요~

Reference : http://httpd.apache.org/docs/current/mod/mod_rewrite.html

 

Leave a Comment