ci 404 問題總結

	protected function getNode(){
		//$CONTROLLER_NAME =  $this->_CI->router->fetch_class();
		//$ACTION_NAME =  $this->_CI->router->fetch_method();    // 當前使用方法
		//$this->node = strtolower($CONTROLLER_NAME.'/'.$ACTION_NAME);
			$file=str_replace("/index.php","",$_SERVER['PHP_SELF']);
		 	$reg="/\/\d+/is";
			$file= preg_replace($reg,"",$file);
			if(substr($file,strlen($file)-1,1)=="/"){
				$file=substr($file,0,strlen($file)-1);
			}
            if(!empty($file)){
                $this->node = $file;
            }else{
                //兼容
                $this->node = $this->getNodeByRouter();
            }
	}

/**
     * _CI->router 獲取url節點
     * test
     * @return string
     */
    protected function getNodeByRouter(){
        $CONTROLLER_NAME =  $this->_CI->router->fetch_class();
        $ACTION_NAME =  $this->_CI->router->fetch_method();
        $node = '/'.$CONTROLLER_NAME.'/'.$ACTION_NAME;
//        print_r($node);die;
        return  $node ;
    }

mac 無法兼容原始方法所以改寫

   $CONTROLLER_NAME =  $this->_CI->router->fetch_class();
        $ACTION_NAME =  $this->_CI->router->fetch_method();
        $node = '/'.$CONTROLLER_NAME.'/'.$ACTION_NAME;

以獲取路由

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章