germanliu
(Germanliu)
June 20, 2013, 9:46pm
1
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
konapaz
(Konapaz)
June 20, 2013, 10:56pm
2
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/
How to create SEO-friendly permalinks in your Yii application, including using slugs, removing index.php, forcing trailing slashes, and clean "/site/page/" URLs
http://www.yiiframework.com/forum/index.php/topic/44433-beautiful-urls-with-slug/page__p__210495__fromsearch__1#entry210495
tgr
(Trond)
June 21, 2013, 11:00am
3
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
germanliu
(Germanliu)
June 21, 2013, 12:33pm
4
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
konapaz
(Konapaz)
June 21, 2013, 9:14pm
5
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
germanliu
(Germanliu)
June 21, 2013, 9:32pm
6
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.
menxaca
(Menxaca)
June 21, 2013, 11:29pm
7
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…
konapaz
(Konapaz)
June 22, 2013, 11:56am
8
germanliu:
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.
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.
Niels
(Niels)
June 24, 2013, 9:55am
9
germanliu
(Germanliu)
June 24, 2013, 12:25pm
10
KonApaz, i.amniels, thank you very much