Request_Uri

For some reason the REQUEST_URI is getting emptied out in the $_SERVER array.

On index.html when ever we run:


print_r($_SERVER);

…the request_uri is displayed correctly to the browser.

But if we create a log file right under the print_r, writing the $_SERVER array, the request_uri value is empty.

I’m not sure how to explain it better. Anyone have ANY ideas as to why this is happening? We’re stumped.

Have you tried getting request URI in YII way?


Yii::app()->request->requestUri

Yii appears to be getting it this way:


public function getRequestUri()

	{

		if($this->_requestUri===null)

		{

			if(isset($_SERVER['HTTP_X_REWRITE_URL'])) // IIS

				$this->_requestUri=$_SERVER['HTTP_X_REWRITE_URL'];

			elseif(isset($_SERVER['REQUEST_URI']))

			{

				$this->_requestUri=$_SERVER['REQUEST_URI'];

				if(!empty($_SERVER['HTTP_HOST']))

				{

					if(strpos($this->_requestUri,$_SERVER['HTTP_HOST'])!==false)

						$this->_requestUri=preg_replace('/^\w+:\/\/[^\/]+/','',$this->_requestUri);

				}

				else

					$this->_requestUri=preg_replace('/^(http|https):\/\/[^\/]+/i','',$this->_requestUri);

			}

			elseif(isset($_SERVER['ORIG_PATH_INFO']))  // IIS 5.0 CGI

			{

				$this->_requestUri=$_SERVER['ORIG_PATH_INFO'];

				if(!empty($_SERVER['QUERY_STRING']))

					$this->_requestUri.='?'.$_SERVER['QUERY_STRING'];

			}

			else

				throw new CException(Yii::t('yii','CHttpRequest is unable to determine the request URI.'));

		}


		return $this->_requestUri;

	}

I’ll try playing around with that function though. Thanks