seo - 如何避免 Zend Framework 中糟糕的 SEO 重复内容 URL

标签 seo duplicates zend-framework

我是 Zend Framework 的新手,我正在构建一个希望实现良好 SEO 实践的网站。

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

所以我在我的 Bootstrap 中创建了这条路线:

$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/巴塞罗那
/es/barcelona/index
/es/巴塞罗那/索引/索引

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

提前致谢!

最佳答案

您正在设置默认值,因此对于一个页面(默认页面),请求将是相同的。如果您删除了默认值,如果 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 的默认值,因为没有这些数据我不确定您的 Controller 是什么将要做的事。

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

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

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

您始终可以添加其他路由以将其他请求(比如 /)映射到相关 Controller 。

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

关于seo - 如何避免 Zend Framework 中糟糕的 SEO 重复内容 URL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8473958/

相关文章:

seo - X-Robots-Tag HTTP header 与 robots.txt 的优先级

php - 在 mysql 列中搜索重复项并在 while 循环中为变量添加后缀

php - php程序查看函数

zend-framework - 将非 Zend_Form 变量传递给 ViewScript

html - Seo:使用 iframe 提高代码文本比?

php - 重定向出站链接和 rel ="nofollow"属性 - 有什么区别?

php - 您建议使用哪种方式使用 php 进行 zend lucene 搜索或使用 lucene 本身并使用 php 进行移植?

session - Zend 框架 session 提前过期

wordpress - 是什么导致了我的 Yoast SEO 站点地图上的 500 错误?

tcp - 使用代理复制 TCP 流量