Zencart消除SEO URL中重复的网址或者页面
2013-06-25 08:47
218 查看
安装了Ultimate SEO URLs,进行了URL伪静态
更改商品分类名称后URL发生了改变,
比如 本来商品分类名称为 DVD Movies
那DVD Movies 的URL为:http://demo.zen-cart.cn/dvd-movies-c-3.html
现在在后台把商品分类DVD Movies改为China DVD Movies
那China DVD Movies 的URL为http://demo.xxx.cn/china-dvd-movies-c-3.html
要命的是:原来的 http://demo.XXX.cn/dvd-movies-c-3.html还可以访问,内容和http://demo.xxx.cn/china-dvd-movies-c-3.html的相同,这2个URL指向的其实是同一个页面.
这个SEO模块是有重复网址的问题,实际上不管分类名称输入什么,都是根据后面的分类编号来打开分类页面的,产品页面也会出现这类重复URL.
解决方法:
首先,商店设置-搜索引擎优化-打开自动跳转吗Cheap Shoes,设置为 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.对分类页面和商品页面都有效
更改商品分类名称后URL发生了改变,
比如 本来商品分类名称为 DVD Movies
那DVD Movies 的URL为:http://demo.zen-cart.cn/dvd-movies-c-3.html
现在在后台把商品分类DVD Movies改为China DVD Movies
那China DVD Movies 的URL为http://demo.xxx.cn/china-dvd-movies-c-3.html
要命的是:原来的 http://demo.XXX.cn/dvd-movies-c-3.html还可以访问,内容和http://demo.xxx.cn/china-dvd-movies-c-3.html的相同,这2个URL指向的其实是同一个页面.
这个SEO模块是有重复网址的问题,实际上不管分类名称输入什么,都是根据后面的分类编号来打开分类页面的,产品页面也会出现这类重复URL.
解决方法:
首先,商店设置-搜索引擎优化-打开自动跳转吗Cheap Shoes,设置为 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.对分类页面和商品页面都有效
相关文章推荐
- ZENCART消除SEO URL中重复的网址/页面
- zencart安装SEO URL插件后出现重复网址或页面解决办法
- 完美解决zencart SEO模块存在重复网址的问题
- 如何用js得到当前页面的url信息方法(JS获取当前网址信息)
- 正则表达式 匹配URL或者网址
- 如何用js得到当前页面的url信息方法(JS获取当前网址信息)
- js如何准确获取当前页面url网址信息
- 如何用js得到当前页面的url信息方法(JS获取当前网址信息)
- 分析输入url到页面返回的过程(或者查询返回过程)
- 关闭子页面刷新父页面时候,Firefox 必须发送将会导致重复之前动作的数据(例如搜索或者下订单)。 ie提示:若要再次显示该页面,web浏览器需要重新发送您以前提交的信息
- js如何准确获取当前页面url网址信息
- ajax页面跳转(后台返回的是一个url地址,或者自己传进去的是url地址)
- js如何准确获取当前页面url网址信息
- 如何用js得到当前页面的url信息方法(JS获取当前网址信息)
- [HTML][Javascrpt]如何取得当前页面网址(URL)和查询参数
- 正则表达式匹配URL或者网址
- 如何用js得到当前页面的url信息方法(JS获取当前网址信息)
- 从一道百度面试题到分析输入url到页面返回的过程(或者查询返回过程)
- js如何准确获取当前页面url网址信息
- 如何用火车头采集当前页面url网址