포럼

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 모듈에서만 동작하는 룰임.

잊어먹지 않기 위해 적어놓는 글이라 새로운 생각이 떠오르면 언제든지 바뀔 수 있습니다.
글쓴이 제목 최종 글
SMaker RewriteEngine class 제안 [7] 2020.03.14 by SMaker
유샤인 제로보드 프로그램이 호스팅서버의 자원을 너무 많이 쓰고 있다며 웹사이트를 정지했는데... [7] 2011.08.17 by 종스
bncPlan 다운로드와 XE market ...  
도라란 주민번호가 아니라면 어떤 방법으로 회원의 실제나이를 알수 있을까요? [13] 2011.08.18 by squarehacker
파랑이지 현재 저는 텍스트큐브 설치형 블로그를 쓰고 있습니다.  
fsfsdas 아마 이러면 되지 않을까요? [3] 2011.08.18 by snows96
파이델 XE market의 프로그램 보호 (모듈,에드온 등...) [6] 2011.08.19 by 파이델
웹 엔진 위젯스타일에서는 textarea가 안되나요?  
웹 엔진 새로운 <위젯 스타일> 제작 착수!! [1] 2011.08.21 by 인간a
zero XE 개발 참여 활성화를 어떻게 하면 좋을까요? [6] 2011.08.22 by 또별
정찬명 XE를 SNS에서도 만나세요! G+ 초대장도 있어요. [9] 2020.03.14 by BNU
이글도적 제로보드 통합 아이디 [7] 2011.08.22 by 엄마네과일가게
SMaker XE를 사용하는 이유가 무엇인가요? [27] 2011.08.22 by 자쿠아
박노열 커뮤니티 메뉴 순서를 바꾸었으면 합니다 [11] 2011.08.22 by snows96
파랑이지 사용자 포럼 이용 가이드 [ver.0.1] [2] 2011.08.22 by snows96
snows96 오.. XpressEngine 에디터랑 위젯에 버그가 있군요  
우진홈 문자 중복 출력 버그(IE6)와 정찬명님의 글 [2] 2011.08.23 by xemall
sejin7940 우연히도 제작한 자료가 겹치는 경우에는 어떻게 되는걸까요? [10] 2011.08.23 by tao
파랑이지 웹서핑하다 킴스큐Rb로 만든 사이트를 보았습니다. [15] 2011.08.23 by zgzg
NetCabin 에디터 검정색 사용하시는분들 계신가요?