포럼

XE의 경우 코어에서 정한 Rewrite rule을 따르고 있습니다.

/document_srl/
/mid/document_srl/
/vid/document_srl/
/vid/mid/document_srl/

하지만 사이트를 만들다보면 이러한 룰은 한계가 있습니다.
주소도 길어지고 외우기 힘들고 지저분해보입니다.

모듈에서 Custom rewrite rule을 지원한다면 좀 더 간결한 주소를 만들 수 있겠죠.

RewriteEngine 클래스 레퍼런스
  • RewriteEngine::set();
  • RewriteEngine::unset();
  • RewrtieEngine::getRules();
  • RewriteEngine::setTargetModule();
  • RewriteEngine::addTargetModule();
  • RewriteEngine::getTargetModules();

<?php
class RewriteEngine {
    var $rules;

    /**
     * @brief constructor
     **/
    function RewriteEngine() {
    }

    function set($regex, $rewrite, $target_module) {
        if(!isset($this->rules[$regex])) {
            $rule = new stdClass;
            $rule->regx = $regex;
            $rule->rewrite = $rewrite;
            $rule->target_module = $target_module;
            $this->rules[$regex][] = $rule;
        }
    }

    function unset($regex, $index = null) {
        if($index) {
            unset($this->rules[$regex][$index]);
        } else {
            unset($this->rules[$regex]);
        }
    }

    function setTargetModule($regex, $target_module) {
        $this->rules[$regex]->target_module = $target_module;
    }

    function getRules() {
        return $this->rules;
    }

    function getTargetModules($regex) {
        return $this->rules[$regex]->target_module;
    }
}
?>

before_module_init 혹은 before_module_proc 시점에서 룰을 추가하거나 삭제할 수도 있고요.

<?php
if($called_position == 'before_module_init') {
    RewriteEngine::set('[a-zA-Z0-9_+]/category/[0-9+]', 'index.php?mid=$1&category_srl=$2', 'board');
}
?>

conf/module.xml 파일에 룰을 선언할 수 있습니다.

<module>
...
<rewriteRules>
    <rule regex="[a-zA-Z0-9_+]/category/[0-9+]" rewrite="index.php?mid=$1&category_srl=$2" module="board" />
    <rule regex="[a-zA-Z0-9_+]/act/write/" rewrite="index.php?mid=$1&act=dispBoardWrite" module="board" />
    <rule regex="[a-zA-Z0-9_+]/act/modify/[0-9+]" rewrite="index.php?mid=$1&document_srl=$2&act=dispBoardWrite" module="board" />
    <rule regex="[a-zA-Z0-9_+]/act/delete/[0-9+]" rewrite="index.php?mid=$1&document_srl=$2&act=dispBoardDelete" module="board" />
</rewriteRules>
...
</module>

module="board"인 경우 board 모듈에서만 동작하는 룰임.

잊어먹지 않기 위해 적어놓는 글이라 새로운 생각이 떠오르면 언제든지 바뀔 수 있습니다.
글쓴이 제목 최종 글
박종식853 갑자기 XE인스톨 화면이 첫화면으로 뜰때(캡쳐有) [1] file 2011.08.31 by 박종식853
oyume CSS 파일 이 빠져있는듯합니다.. 이유를 모르겠습니다. [1] 2011.08.30 by 웹 엔진
sejin7940 혹시 Zend Guard 써보신 분 계신가요? [8] 2011.08.29 by 비나무
씨지 게시판'스킨 관리'가 최고관리자만 되네요. 이번 업데이트 후에그런건지 [12] 2011.08.29 by 씨지
맑은여름 1.4.5.9 에서도 그룹추가 관련 에러는 고쳐지지 않았습니다. [4] file 2011.08.29 by 맑은여름
도라란 에디터, 무엇을 사용하시는지요? (파일 첨부가 주로 많은 사이트) [4] 2011.08.28 by 유샤인
씨지 DB에서 제목순 정렬 속도를 높이려면? [1] 2011.08.27 by 씨지
영구만세 첨부파일의 권한관리 [2] file 2011.08.26 by 영구만세
우진홈 iPad CSS Layout for XE! 학습자료입니다. [4] file 2011.08.24 by 우진홈
ㅠ도라에몽ㅠ 사용자의 os언어에 따라 홈페이지의 접속을 다르게하는법....이 있는가요? [1] 2011.08.24 by 송동우
NetCabin 에디터 검정색 사용하시는분들 계신가요?  
파랑이지 웹서핑하다 킴스큐Rb로 만든 사이트를 보았습니다. [15] 2011.08.23 by zgzg
sejin7940 우연히도 제작한 자료가 겹치는 경우에는 어떻게 되는걸까요? [10] 2011.08.23 by tao
우진홈 문자 중복 출력 버그(IE6)와 정찬명님의 글 [2] 2011.08.23 by xemall
snows96 오.. XpressEngine 에디터랑 위젯에 버그가 있군요  
파랑이지 사용자 포럼 이용 가이드 [ver.0.1] [2] 2011.08.22 by snows96
박노열 커뮤니티 메뉴 순서를 바꾸었으면 합니다 [11] 2011.08.22 by snows96
SMaker XE를 사용하는 이유가 무엇인가요? [27] 2011.08.22 by 자쿠아
이글도적 제로보드 통합 아이디 [7] 2011.08.22 by 엄마네과일가게
정찬명 XE를 SNS에서도 만나세요! G+ 초대장도 있어요. [9] 2020.03.14 by BNU