zencart安装SEO URL插件后出现重复网址或页面解决办法
2013-08-09 15:25
633 查看
这个问题困扰了包括我在内的很多同志,今天看到zen-cart.cn上面Jack老大回复的一个帖子,把它转过来大家一起参考下。
首先,商店设置-搜索引擎优化-打开自动跳转吗?,设置为 true
然后打开文件 \includes\classes\seo.url.php
在其前面加上以下代码:
上面的代码,自动分析请求的URL,如果URL中分类、商品名称与数据库里的不一样,就自动跳转到正确的页面,这样就消除了重复URL。对分类页面和商品页面都有效。
that 's all .
免责生明:
本内容转载自:http://www.zen-cart.cn/forum/topic14264.html
如有侵权,请联系我,我将第一时间删除。
欢迎广大同行朋友拍砖。
首先,商店设置-搜索引擎优化-打开自动跳转吗?,设置为 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
上面的代码,自动分析请求的URL,如果URL中分类、商品名称与数据库里的不一样,就自动跳转到正确的页面,这样就消除了重复URL。对分类页面和商品页面都有效。
that 's all .
免责生明:
本内容转载自:http://www.zen-cart.cn/forum/topic14264.html
如有侵权,请联系我,我将第一时间删除。
欢迎广大同行朋友拍砖。
相关文章推荐
- ZENCART消除SEO URL中重复的网址/页面
- Zencart消除SEO URL中重复的网址或者页面
- SQL Server 2000安装重复出现挂起问题解决办法
- vs code 安装插件出现XHR error 解决办法
- SQLServer 2K 安装重复出现挂起问题解决办法
- 解决eclipse安装插件时出现重复安装错误问题的小插件
- ubuntu下面出现无法使用刚安装eclipse的插件的问题,解决办法
- 关于ubuntu16.4 中安装最新的eclipse或者是STS出现页面特卡,且新建项目没有提示,preference选项中点击左侧标签右侧没反应的解决办法,参照google, 排版不太好,希望对一些小伙伴有所帮助
- Discuz x2插件可以安装和卸载,点击启用之后页面空白的解决办法 [原创]
- python2.7,Ubuntu14.04环境下pip安装插件,cffi插件出现一下错误解决办法。
- ElasticSearch6.0安装head插件出现问题解决办法
- WordPress升级版本及安装插件出现”Problem with the SSL CA cert”的解决办法
- 完美解决zencart SEO模块存在重复网址的问题
- SQLServer 2K 安装重复出现挂起问题解决办法
- LNMP一键安装环境 wordpress后台部分页面出现502解决办法
- JSP页面多次提交时(后台对表单有校验功能 )提示信息重复出现解决办法
- SQLServer 2K 安装重复出现挂起问题解决办法
- 刷新网址栏导致页面重复提交解决办法
- SQLServer 2K 安装重复出现挂起问题解决办法
- ZENCART晚点出现 -c-.html 网址的 解决办法