CodeIgniter_2 路由中定义伪静态 直接映射到相关的控制器

某些情况下 隐藏路径信息 使用伪静态定义:

RewriteRule ^no/torrent(.*)$ /index.php/torrent/doit/$1

CodeIgniter会自动识别到 no 控制器,但是我其实想识别到 torrent 控制器 

需要对 core\URI.php 文件进行处理下

	/**

	 * Detects the URI

	 *

	 * This function will detect the URI automatically and fix the query string

	 * if necessary.

	 *

	 * @access	private

	 * @return	string

	 */

	private function _detect_uri()

	{

		if ( ! isset($_SERVER['REQUEST_URI']) OR ! isset($_SERVER['SCRIPT_NAME']))

		{

			return '';

		}



		$uri = $_SERVER['REQUEST_URI'];



		//添加的数据 重新定义url

        if(isset($_SERVER['PHP_SELF'])){

	        if($_SERVER['PHP_SELF'] != '' and $_SERVER['PHP_SELF'] != $_SERVER['REQUEST_URI']){

		        $uri = $_SERVER['PHP_SELF'];

		        if(isset($_SERVER['QUERY_STRING']) and $_SERVER['QUERY_STRING'] != ''){

			        $uri = $uri.'?'.$_SERVER['QUERY_STRING'];

		        }

	        }

        }

        //来自 吠品 http://www.cnblogs.com/osfipin/



		

		if (strpos($uri, $_SERVER['SCRIPT_NAME']) === 0)

		{

			$uri = substr($uri, strlen($_SERVER['SCRIPT_NAME']));

		}

		elseif (strpos($uri, dirname($_SERVER['SCRIPT_NAME'])) === 0)

		{

			$uri = substr($uri, strlen(dirname($_SERVER['SCRIPT_NAME'])));

		}



		// more

	}

  CodeIgniter 3.0 对 这个文件进行了重构。想实现这个需求 貌似也不行,大家可以测试一下子。

你可能感兴趣的:(CodeIgniter)