Seo Unique Urls

HI to all!

I have the following doubt. By default Yii comes with 3 (or even more) ways to direct someone to the same page. And that is not SEO friendly. For example:

article/write/id/5

article/write?id=5

article/5

Any idea on how to address this issue?

Thanks!

German

Hi germanliu

The default Yii way is using urlManager in config/main.php

Check this

http://www.yiiframework.com/wiki/427/htaccess-seo-friendly-url/

http://www.yiiframework.com/forum/index.php/topic/44433-beautiful-urls-with-slug/page__p__210495__fromsearch__1#entry210495

This should not be a problem.

When you have the config properly set up, only one type of links will be used.

So the search engines will never see several identical pages with duplicated content.

Norwegian

Hi, thanks for your replies.

I’ve reviewed the information you sent me but there is something that I still don’t get.

How should I configure urlManager to avoid the following:

www.mydomain.com

www.mydomain.com/site (site is the default controller)

www.mydomain.com/site/index (index is the default action)

All this three URLs point to the same page… and this is not good.

Try:

http://www.yiiframework.com/site/index

http://www.yiiframework.com/site/

http://www.yiiframework.com/

http://www.yiiframework.com/index.php/site/index

http://www.yiiframework.com/index.php/site/

http://www.yiiframework.com/index.php

http://www.yiiframework.com/index.php?r=site/index

http://www.yiiframework.com/?r=site/index

All show the same Yii Framework home page… is it possible to avoid this? How?

Thanks a lot!!!!

German

I think it is good

www.mydomain.com (default controller with default action)

www.mydomain.com/site (specific ‘site’ controller with default action)

www.mydomain.com/site/index (specific ‘site’ controller with ‘specific’ action)

all of this cases automatically runs the same controller/action without specific the controller and action to be required

So why you thing that is not good?

Yes you can avoid this, see a relative post

http://www.yiiframework.com/forum/index.php/topic/44433-beautiful-urls-with-slug/page__p__210495__fromsearch__1#entry210495

In terms of SEO its no good to have same content on several URLS… and that is what happens.

I realized that setting useStrictParsing to true in urlManager eliminates some combinations, but not all.

I read your link, but still don’t get how to avoid this behavior. I appreciate if you can guide me a little.

Hi germanliu,

As you say, having several URL’s going to the same content is not good for search engines, but… when a search engine, like Google, tries to index your pages only will find the url that you have setup in your urlManager, only if someone write that address directly in the web browser is when the search engine will detect that there are two URL’s pointing to the same content.

Maybe I’m wrong…

Ok, if you want to avoid multipe url of one contenct you can do it in this way

In your config main.php in urlmanager block add this code


'urlFormat'=>'path',

'showScriptName'=>false,

'rules' => array(

'site'=>'site/error'

'site/index'=>'site/error'

With that, all the extra url: /site /site/index ?r=site ?r=site/index will routed to the error page like other not existance pages does.

Have a look at the canonical meta tag: http://googlewebmastercentral.blogspot.nl/2009/02/specify-your-canonical.html

KonApaz, i.amniels, thank you very much