zen-cart网站,模版,采集,二次开发

首页 » ZenCart » ZenCart教程 » 阅读文章

消除Ultimate SEO URLs伪静态插件页面网址重复

2011-05-17 16:08 37930 4 发表评论
标签:


Ultimate SEO URLs模块是有重复网址的问题,实际上不管分类或者产品名称输入什么,都是根据后面的分类id来打开分类页面的,这样当我们修改分类名或者标题名是就会产生重复页面。

解决方法

1.商店设置-搜索引擎优化-打开自动跳转吗?,设置为 true

对应英文版:Configuration-SEO URLs-Enable automatic redirects?-true

2.打开文件 \includes\classes\seo.url.php,找到:

$this->attributes['SEO_REDIRECT']['NEED_REDIRECT'] = $this->need_redirect ? 'true' : 'false';

在前面加上:

  // check product name from URL and redirect if not equal to real product name to avoid duplicates
      if ( preg_match('/-p-[0-9]/i', $this->uri) && preg_match('/main_page=product_info/i', $this->real_uri) ) {
         $productname_from_url = preg_replace('/-p-[0-9].*/i','',$this->uri);
         $productid_from_url= preg_replace('/.*-p-([0-9]+)\.html/i','$1',$this->uri);
         if ( $this->get_product_name($productid_from_url) != $productname_from_url ) {
            $this->need_redirect = true;
         // repeating procedure from function check_redirect() but for real_uri
         if ($this->is_attribute_string($this->real_uri)) {
         $parsed_url = parse_url($this->real_uri);
         $this->uri_parsed = parse_url($parsed_url['scheme']);
         $this->uri_parsed['query'] = preg_replace('/products_id=([0-9]+)/', 'products_id=$1:' . $parsed_url['path'], $this->uri_parsed['query']);
      } else {
         $this->uri_parsed = parse_url($this->real_uri);
      }
        }
      } // end of product_info URL redirect

    // check category name from URL and redirect if not equal to real category name to avoid duplicates
      if ( preg_match('/-c-[0-9]/i', $this->uri) && preg_match('/main_page=index/i', $this->real_uri) ) {
         $categoryname_from_url = preg_replace('/-c-[0-9].*/i','',$this->uri);
         $categoryid_from_url= preg_replace('/.*-c-([0-9]+)\.html/i','$1',$this->uri);
         if ( $this->get_category_name($categoryid_from_url) != $categoryname_from_url ) {
          $this->need_redirect = true;
         // repeating procedure from function check_redirect() but for real_uri
         if ($this->is_attribute_string($this->real_uri)) {
         $parsed_url = parse_url($this->real_uri);
         $this->uri_parsed = parse_url($parsed_url['scheme']);
         $this->uri_parsed['query'] = preg_replace('/cPath=([0-9]+)/', 'cPath=$1:' . $parsed_url['path'], $this->uri_parsed['query']);
      } else {
         $this->uri_parsed = parse_url($this->real_uri);
      }
         }
      } // end of category URL redirect

附改好的一个seo.url.php,下载地址:http://dl.dbank.com/c0ebnoyz5e

相关日志:

评论 共4条 (RSS 2.0) 发表评论

  1. adz 说道:

    LZ的站很多资料非常好,值得收藏。

  2. sakura 说道:

    博主 windows主机 iis6环境 商店设置-搜索引擎优化-打开自动跳转吗?,设置为 true
    打开这个后无法打开内页, 提示有过多的重定向, 是怎么回事呢?

  3. zhang7725952 说道:

    怎么下载不了

发表评论

  • 
  • 插入代码

联系我 Contact Me

回到页首