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:
.../post/show/id/100
become
.../post/100-title-of-my-post.html
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){
redirect(createUrl(the-new-cool-url)),
}
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