最近公司新上的网站被seo指出要修改url,去掉url中产品id。由于我们用的是zencart框架,装了 Ultimate SEO URLs 插件,所以在网上应该有这方面的资料,本文主要参考资料:

原网址:http://leezhxing.blog.51cto.com/6634351/1282790

原文只介绍了修改产品页,我在修改过程中一并把分类页也进行了修改,下面为原文修改产品页内容,其中有些错误用红色字体更正。

以前用Ultimate SEO URLs模块 产品地址是这样的

http://www.xxx.com/产品名-p-101.html
通过下面方法我们改成这样的格式
http://www.xxx.com/产品名/

1.includes/init_includes/init_category_path.php(原先是includes/modules/pages/product_info/header_php.php 但不能引用到导航)
头部添加
if(zen_not_null($_GET['products_name'])){
$products_id_query=$db->Execute("select products_id from ".TABLE_PRODUCTS_DESCRIPTION.' where products_name="'.str_replace("-"," ",$_GET['products_name']).'"');
if($products_id_query->RecordCount()>0)
$_GET['products_id']=$products_id_query->fields['products_id'];
}
2.includes/classes/seo.url.php
约401行查找
$url = $this->make_url($page, $this->get_product_name($p2[1]), $p2[0], $p2[1], '.html', $separator);
替换为 
$url = $this->make_url($page, $this->get_product_name($p2[1]),'', '', '/', '');

此处替换为:$url = $this->make_url($page, $this->get_product_name($p2[1]), '', '', '.html', $separator);
3.htaccess
查找
RewriteRule ^(.*)-p-(.*).html$ index\.php?main_page=product_info&products_id=$2&%{QUERY_STRING} [L]
替换为
RewriteRule ^(.*)\/$ index\.php?main_page=product_info&products_name=$1&%{QUERY_STRING} [L]

注意事项 
1.产品名中不能出现- 可用空格来表示
2.产品名不能重复
3.类似后台admin这种的 必须要直接访问文件了 比如http://www.xxx.com/admin/index.php

-----------------------------更新分割线-----------------------------------------
有人问怎么样才能显示成http://www.xxx.com/目录名/产品名/ 这样的方式
修改方法如下
1.includes/init_includes/init_category_path.php(原先是includes/modules/pages/product_info/header_php.php 但不能引用到导航)
头部添加
if(zen_not_null($_GET['products_name'])){
$products_id_query=$db->Execute("select products_id from ".TABLE_PRODUCTS_DESCRIPTION.' where products_name="'.str_replace("-"," ",$_GET['products_name']).'"');
if($products_id_query->RecordCount()>0)
$_GET['products_id']=$products_id_query->fields['products_id'];
}
2.includes/classes/seo.url.php
约401行查找
$url = $this->make_url($page, $this->get_product_name($p2[1]), $p2[0], $p2[1], '.html', $separator);
替换为 
$url = $this->make_url($page, zen_get_categories_name_from_product($p2[1]).'/'.$this->get_product_name($p2[1]),'', '', '/', '');

3..htaccess
查找
RewriteRule ^(.*)-p-(.*).html$ index\.php?main_page=product_info&products_id=$2&%{QUERY_STRING} [L]
替换为
RewriteRule ^(.*)\/(.*)\/$ index\.php?main_page=product_info&products_name=$2&%{QUERY_STRING} [L]
注:这次后台就可以直接访问了 当然有两级目录的话就不行。

zencart分类页产品页去掉url中的id号的更多相关文章

  1. Dedecms去掉URL中a目录的方法

    本文实例讲述了Dedecms去掉URL中a目录的方法.分享给大家,供大家参考.具体分析如下: 使用dedecms的朋友可能会发现自己的URL目录生成是会自动带有一个/A/目录了,那么要如何去掉URL中 ...

  2. 【代码笔记】iOS-请求去掉url中的空格

    一,代码. - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view, ...

  3. CI在nginx环境下去掉url中的index.php

    在nginx环境下CI框架默认URL规则访问不了,出现500错误,如: http://blog.php230.com/index.php/keywords 今天在服务器配置CI框架环境时,去除URL中 ...

  4. url中出现井号("#")的问题

    今天在asp.net mvc网站项目的前台页面里写一段js代码时,想要跳转到某个url,例如 location.href="xxxx?"+"id="+id+&q ...

  5. ASP.NET MVC Url中带点号出现404错误的解决方案

    由于项目需求,项目的路由设计如下 config.Routes.MapHttpRoute( name: "Get/Put Sku", routeTemplate: "api ...

  6. angluar去掉url中#

    众所周知,angular项目中路由机制会在地址栏加一个#来实现各个页面的切换,虽然url中有个#号也无伤大雅,但每次看到多一个这个东西总是不舒服(我不是强迫证啊),趁着项目间隙还是决定把它去掉. 去谷 ...

  7. VUE项目问题之:去掉url中的#/

    一.问题 使用VUE路由,项目的url总是带有锚点,如下: http://localhost:8082/#/ 二.解决 修改路由文件中 index.js 文件,即 src --> router ...

  8. CI去掉 URL 中的 index.php

    首先,你要清楚自己的 Web 服务器是 Apache,支持 mod_rewrite 查找httpd.conf中是否开启了mod_rewrite.so 然后,在 CI 根目录下新建立一个配置文件,命名为 ...

  9. CI 框架去掉url 中index.php的方法

    1 修改 apache 的 httpd.conf 文件 #LoadModule rewrite_module modules/mod_rewrite.so 去掉前面的# 2 找到 你程序目录下的 .h ...

随机推荐

  1. mysql基础语法及拓展到web中的sql注入

    本来是想写下javaweb的mvc(tomcat, spring, mysql)的搭建,  昨天搭到凌晨3点, 谁知道jdbcTemplate的jar包不好使, 想死的心都有了, 想想还是休息一下, ...

  2. bootstrap-fileinput简单完整列子

    文件夹结构 版本都是3.x <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http ...

  3. python面试大全

    问题一:以下的代码的输出将是什么? 说出你的答案并解释. class Parent(object): x = 1 class Child1(Parent): pass class Child2(Par ...

  4. HTTP协议学习--- (十一)理解HTTP幂等性

    在httpcomponent 文档中看到如下段落: 1.4.1. HTTP transport safety It is important to understand that the HTTP p ...

  5. ASP.net mvc Code First 更新数据库

    code first 数据库迁移步骤如下: 第一步:Add-Migration DataBase_Init 1. Install-Package EntityFramework.zh-Hans –Ve ...

  6. Java RTTI机制与反射机制

    1.1 什么是RTTI? 维基百科的定义:In computer programming, RTTI (Run-Time Type Information, or Run-Time Type Iden ...

  7. Linux文件系统介绍(转)

    文章转自:http://www.iteye.com/topic/816268 文件系统是linux的一个十分基础的知识,同时也是学习linux的必备知识. 本文将站在一个较高的视图来了解linux的文 ...

  8. 嵌入式环境下通过 UDP 链接来调试 QT 程序

    据说有为嵌入式提供的 QT Debug 手段,但是目前还没发现,所以想到了这个笨办法.有更好思路的可以推荐. 该思路是基于 QDebug() .因为 QT 提供了重写 QT msg 处理方法的接口 q ...

  9. FT232RL变砖之后

    FT232RL是个是神奇的片子,说万能可能有些夸张,但是...总之就是FTDIChip这个神奇的公司基于类似的技术,做了很多好用的产品,包括转IIC啦,转SPI啦,密码狗啦之类的.是个很有用的工具就对 ...

  10. 使用dnsmasq来提升CentOS上网速度

    1. 安装dnsmasq dnsmasq的官方网址是:http://www.thekelleys.org.uk/dnsmasq/doc.html.利用里面的下载链接下载dnsmasq-2.72.tar ...