URL manager causes page to load twice?

It seems like when I use the URL manager (I’m using ‘urlFormat’=>‘path’) and try to access a URL using one of the rules, the page is actually loaded twice.

I realized this because on some of my pages I increase a views variable by 1 each time someone views the page, and for some reason it was always increasing by 2.

Is there a way to fix this, or is this a bug?


I have a problem like that too, if I try to login/logout, I need to change to the contact site first before the

session is really cancelled, can anyone tell me what happens there? It happens with the generated yiic code that I’ve used together with the yii guide.

Thanks in advance.

Could you dump debug_backtrace() into a file and see if it happens twice and what the content is?

Hy All

First of all, I wish for all of you an happy new year …

I’ve the quite the same problem depicted in this post.

In fact sometimes my javascript files are loaded twice and sometimes not.

It seems it comes from the Url (two kinds of Url lead to those two kinds of behaviors)

I try to do URL SEO friendly then I have Url like this

http://localhost/mySite/xxx => Then no problem

http://localhost/mySite/xxx/yyy => Then my scripts are loaded twice.

It seems strange because jquery library, loaded with registerCoreScript is never loaded twice.

When all things work well I have, for a javascript file, with Firebug, 2 "404 CHttpException"

Do you know what is the problem ?


Could you check if it is a problem of your Javascript files inclusion?



Crap, does this mean the problem hasn’t been solved? I’m building a forum, and using the URLManager as well - though it does not matter whether I use the shortened version or the full one. I use ‘++$topic->view_count’ (I’ve tried every other increment form, so that’s not it), but it increments twice.

Odd thing is, I’ve tried using ‘echo ++$topic->view_count’ to display what it’s doing, and it only increments once there - so it’s actually displaying the first run, and the second run is just being eaten. But I have checked the database before navigating away, and I can absolutely confirm that it’s doubling on page load, not anything else.

Edit: I did a debug_backtrace() dump, and it did indeed create two files (naming based on the view count) for a single page load. It’s a full 1.1MB in each file, and I have no idea what I’m looking for, but I did run a diff on them - the only difference is the user’s last online time, a change of two seconds. Not one other line changed between the two loads.

I think what might be happening is more than one rule gets applied, even though it should stop at the first match. If I take out all the rules except one, it seems to work as expected. I haven’t tried some of the new rules options in 1.1.7, that might work for my case, but it seems like it shouldn’t ever load more than once regardless.

I only have 1 rule that matches my controller/action, and it still loads the same action twice


has this topic been solved or cleared ?

I just notuiced the same issue since I needed to log a users visit to an action

the action is called twice therefore my log is duplicated unnecessarely

Thanks for any feedback

dont understand how it is possible… you sure no javascript there?

Turn off javascript and try again

This can also happen when you include external files that are rewritten to the current URL instad of the static file. Also CSS can cause this when you use background:url(’.’); or something similar…