Yii Framework Forum: UrlManager replication problem for SEO - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

UrlManager replication problem for SEO Rate Topic: ****- 1 Votes

#1 User is offline   sp1D3R 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 13
  • Joined: 28-January 10

Posted 22 June 2010 - 04:00 AM

Hi!
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!
0

#2 User is offline   Mike 

  • Elite Member
  • PipPipPipPipPip
  • Yii
  • Group: Members
  • Posts: 3,016
  • Joined: 06-October 08
  • Location:Upper Palatinate

Posted 22 June 2010 - 04:32 AM

Your URL rule looks like this, i guess:

'post/<id:\d+>-<title>.html'=>'post/view',


So you could add another rule:

'post/<id:\d+>'=>'post/view',


and in your post/view action:

if (empty($_GET['title']))
  $this->redirect($your_full_url_here);


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

#3 User is offline   andy_s 

  • Random Member Title
  • Yii
  • Group: Moderators
  • Posts: 1,526
  • Joined: 22-June 09
  • Location:Russia, Kostroma

Posted 22 June 2010 - 04:34 AM

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? :)
1

#4 User is offline   sp1D3R 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 13
  • Joined: 28-January 10

Posted 22 June 2010 - 04:46 AM

View Postandy_s, on 22 June 2010 - 04:34 AM, said:

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!
0

#5 User is offline   andy_s 

  • Random Member Title
  • Yii
  • Group: Moderators
  • Posts: 1,526
  • Joined: 22-June 09
  • Location:Russia, Kostroma

Posted 22 June 2010 - 04:56 AM

View Postsp1D3R, on 22 June 2010 - 04:46 AM, said:

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 :)
0

#6 User is offline   sp1D3R 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 13
  • Joined: 28-January 10

Posted 22 June 2010 - 05:06 AM

View Postandy_s, on 22 June 2010 - 04:56 AM, said:

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.
0

#7 User is offline   andy_s 

  • Random Member Title
  • Yii
  • Group: Moderators
  • Posts: 1,526
  • Joined: 22-June 09
  • Location:Russia, Kostroma

Posted 22 June 2010 - 05:14 AM

View Postsp1D3R, on 22 June 2010 - 05:06 AM, said:

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'

0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users