PHP_SELF returns index.php if showScriptName=false

Hi all,

probably a simple question, but I’m kind of a newbie…

Problem is: I have a map view which I call using /webapp/order/map (I have set showScriptName to false in main config, before it was /webapp/index.php/order/map where "order" is the name of my controller and "map" is the view name).

On this map, there is a form that points to $_SERVER[‘PHP_SELF’] as an action. When “showScriptName” was true, it all worked perfectly well. Now as “showScriptName” is set to false, I have the problem that submitting this form always calls the index.php file (which is the content of the PHP_SELF variable, as I learned from echoing it) instead of /order/map, so when I click the submit button, the home page is displayed and the map view vanishes.

How can I solve this…? Same with $this->refresh() (in another view) brings me to index.php instead of the actual view from which it was called…

Hope you can help me…


The PHP_SELF variable will always include the currently executing script, which will always be the entry script ‘index.php’ if you are using the Yii Framework. If you want to access the current url path, you can use


I’m not sure about the problem with $this->refresh(). Can you paste your code for the ‘urlManager’ in the config file, your .htaccess file, and the context of the call to $this->refresh()?

You should not rely on PHP_SELF, better to explicitely write the url.

You can create the url with CHtml::normalizeUrl();

Thank you so much, guys, Yii::app()->request->url really did the trick. Sometimes things can be so easy…

Thanks again !!