How to extend CHttpRequest?

I want to extend/change the CHttpRequest class in order to change the "getScriptUrl()"-Function. Is this possible without touching any framework files?


Is their a way to put the entry-script into such a directoy structure without having problems?


   -> .htaccess

   -> css

   -> images

   -> yii

      -> index.php

      -> application

      -> framework

So what I want is to not have the entry-script (index.php) in the www-root-directory. Currently I get "/yii" when doing -> die(Yii::app()->urlmanager->baseUrl);

I know this is minor, but I like to have this structure. Thanks for any help.

You may want to extend CHttpRequest as usual, then configure the ‘request’ application component as array(‘class’=>‘’).

You don’t have to do anything in order to have that specific directory structure. Rename ‘protected’ to ‘application’, and you’re done.

Oh, I didn’t knew I can extend the request component that easy :)

No the problem is that I have the index.php one directory under the .htaccess file. It came to (controller/action) errors that way because the request-class included the “yii” folder in the scriptUrl (getScriptUrl()-function). I’ve now fixed it like this:


class HttpRequest extends CHttpRequest


	private $_scriptUrl;

	public function getScriptUrl()


		$this->_scriptUrl = '/';

		return $this->_scriptUrl;





Thank you for your help.

If you just want to set scriptUrl, you don’t even need to extend CHttpRequest. You can set this property in app config:


Wow now that’s easy. Shame on me. Thanks qiang.

Man, thanks for this tip. Just what I needed!