周梦康 发表于 2014-03-27 3713 次浏览 标签 : ZzBlog

伪静态地址rewrite到实际地址交给nginx来做,实际地址访问,跳转到伪静态地址还是php这边直接来完成。

if(defined('ROUTE') && ROUTE){
    if(strstr($_SERVER['REQUEST_URI'],'index.php')){
        parse_str($_SERVER['QUERY_STRING'],$params);
        if(in_array($params['a'],array('blog','bloglist','readbytags'))){
            switch(strtolower($params['a'])){
                case 'blog':
                    $route = $params['id'];
                    break;
                case 'bloglist':
                    $type = array(1=>'notebook',2=>'homesick',3=>'playground');
                    $route = $type[$params['nav']];
                    break;
                case 'readbytags':
                    $route = 'tag-'.$params['tag'];
                    break;
            }
            if($params['p']<2){
                header('Location:'.SITE.'/'.$route.'.html');
            }else{
                header('Location:'.SITE.'/'.$route.'-'.$params['p'].'.html');
            }
        }
    }
}

评论列表