今天解决了一个新问题,特意发上来跟大家一起分享.

zencart老鸟们都知道, 当你修改zencart 分类名称或者商品名称后,修改后的URL和修改前的不同的,而且修改前的URL还是可以打开. 这样就会出现完全相同的两个页面, 这样的页面对搜索引擎来说是很不友好的. 这个就是seo模板存在的网址重复问题,下面是解决方案:

第一步: 商店设置-搜索引擎优化-打开自动跳转吗?,设置为 true  (这一步非常重要)
第二步:   打开文件/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