繁体   English   中英

如何避免Zend Framework中不良的SEO重复内容URL

[英]How to avoid bad SEO duplicated content URLs in Zend Framework

我对Zend Framework还是很陌生,并且正在建立一个网站,希望能够实施良好的SEO做法。

URL结构为:
example.com/language/city/controller/action

因此,我在引导程序中创建了以下路线:

$front = Zend_Controller_Front::getInstance();
$router = $front->getRouter();
$route = new Zend_Controller_Router_Route(':language/:city/:controller/:action/*',
                                         array('language'=>'es',
                                               'city'=>'barcelona',
                                               'controller'=>'index',
                                               'action'=>'index'));
$router->addRoute('language_city', $route);

我不确定可以,但似乎可以解决问题。

接下来,我注意到所有这些URL都指向相同的内容(不良的SEO做法):

/
/es
/es/barcelona
/es/barcelona/index
/es/barcelona/index/index

有没有办法解决这个重复的内容问题?

提前致谢!

您正在设置默认值,因此对于一个页面(默认页面)来说,请求将是相同的。 删除默认值后,如果URI不包含变量,则会收到错误消息(我相信是404 )。

$route = new Zend_Controller_Router_Route(
    ':language/:city/:controller/:action/*',
    array('language'=>'es', //default when not in URI
          'city'=>'barcelona', //default when not in URI
          'controller'=>'index', //default when not in URI
          'action'=>'index' //default when not in URI
    )
 );

似乎您可能要删除 language city 的默认值 ,因为如果没有该数据,我不确定您的控制器将要做什么。

如果这样做,唯一的“重复” URI将是:

/es/barcelona
/es/barcelona/index
/es/barcelona/index/index

但是您只需要使用这些URI之一 如果使用Zend的View_Helper_Url输出链接,则它将删除index/index -因为它与默认值匹配。

您始终可以添加其他路由,以将其他请求(例如/ )映射到相关控制器。

还应注意, 如果只有一个控制器处理所有这些“城市”请求,则无需将其放在URI上

$route = new Zend_Controller_Router_Route(
    ':language/:city/:action/*',
    array('language'=>'es', //default when not in URI
          'city'=>'barcelona', //default when not in URI
          'controller'=>'index', //all requests route here
          'action'=>'index' //default when not in URI
    )
 );

那么唯一的“重复” URI是:

/es/barcelona
/es/barcelona/index

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM