UrlManager replication problem for SEO


I’m writing a web-application, and SEO is very important to us, cause we want to be founded on google sooo much.

So… i writed a Url Rule for posts:




and i put it in UrlManager. It works, great… but… I see that both the url are still active, and that’s not good for us.

I’d like that the second url redirect to the first… this because Google and the other SE don’t like the same content on two different url, and this could be potentially a damage for my application and for the project.

Some advice? I could write something like an IF at the beginning of the show action, something like

if(the url is not rewrited){



Thank you!

Your URL rule looks like this, i guess:


So you could add another rule:


and in your post/view action:

if (empty($_GET['title']))


Since you have the post ID, you can fetch the Post record from DB and create the right full URL including the title.

You can set CUrlManager.useStrictParsing property to "true".

But one question: if there won’t be urls like “/post/show/id/100” on your pages, then how will Google find them? :)

Thank you both! I think that the parameter useStrictParsing is what i was looking for… I have read the documentation, but maybe I didn’t understood the function of that parameter.

I dont’ understand your question: google must find only url “post/100-cool-title.html”, I have put createUrl pratically anywere in my code to do that… my target was to make not accessible the other urls! Google not likes duplicated pages!

If a user will try to access url "/post/show/id/100", then he will get a 404 error. So it is what you are looking for.

Maybe my question wasn’t very serious. I am just interested: if you have only urls of 2nd type on your site, then Google will never find a url of the 1st type :)

And that’s good for SEO! Google “seo duplicate content penalty”…

Anyway… the parameter block ALL the urls, not only those that have a rewriting rule… now my site/index view is a 404 error… bwwwh.

Yes, you need all your pages to have corresponding url rules in CUrlManager. For site/index you need:

'/' => 'site/index'