如何在Zend框架中避免糟糕的SEO重复内容URL

如何在Zend框架中避免糟糕的SEO重复内容URL,seo,duplicates,zend-framework,Seo,Duplicates,Zend Framework,我是Zend框架的新手,我正在建立一个网站,希望实现良好的SEO实践 URL结构将为: example.com/language/city/controller/action 因此,我在引导中创建了以下路线: $front = Zend_Controller_Front::getInstance(); $router = $front->getRouter(); $route = new Zend_Controller_Router_Route(':language/:city/:cont

我是Zend框架的新手,我正在建立一个网站,希望实现良好的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
    )
 );
看起来您可能想删除
语言的默认设置
城市
,因为如果没有这些数据,我不知道您的控制器将做什么

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

/es/barcelona
/es/barcelona/index
/es/barcelona/index/index
但是您只需要使用这些URI中的一个。如果您使用Zend的
查看\u Helper\u Url
输出链接,它将删除
索引/索引
,因为它与默认值匹配

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

还应注意,如果只有一个控制器处理所有这些“城市”请求,则不需要将其放在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

您正在设置默认值,因此对于一个页面(默认页面),请求将是相同的。如果删除了默认值,那么如果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
    )
 );
看起来您可能想删除
语言的默认设置
城市
,因为如果没有这些数据,我不知道您的控制器将做什么

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

/es/barcelona
/es/barcelona/index
/es/barcelona/index/index
但是您只需要使用这些URI中的一个。如果您使用Zend的
查看\u Helper\u Url
输出链接,它将删除
索引/索引
,因为它与默认值匹配

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

还应注意,如果只有一个控制器处理所有这些“城市”请求,则不需要将其放在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

@XeL很乐意提供帮助-可能值得一看各种路由器类型。如果你在做基本的CRUD,我发现REST路由器很有用。@XeL很乐意提供帮助-可能值得一看各种路由器类型。如果你在做基本的CRUD,我发现剩下的路由器很有用。