zoukankan      html  css  js  c++  java
  • ECSHOP程序SEO完全优化

    一、完全自定义页面titile,完全抛弃Ecshop定义的页面title格式:[产品名称]_[分类名]_[网店名称]-Powered by ECShop

    1、分析:大家都知道,titile,kewords,description在SEO中的基础性和重要性,但是ECshop官方给出的titile实现方法会出现很多类似或相同的页面title,另外还有部分页面无法自定义kewords和 description。在此本人给出了完全自定义的方法,其实方法很简单的,只要稍微懂得一点点代码的都会。

    2、修改包括:品牌页,商品页,商品分类页,文章页,文章分类页

    3、修改涉及的页面: 品牌页(增加title,keywords和description):brand.php、admin\brand.php、 admin\templates\brand_info.htm

    商品页(增加title):goods.php、admin\goods.php、 admin\templates\goods_info.htm

    商品分类页(增加title):category.php、admin\category.php、 admin\templates\category_info.htm

    文章页面(增加title):article.php、admin\article.php、 admin\templates\article_info.htm

    文章分类页(增加title):article_cat.php、admin\articlecat.php、 admin\templates\articlecat_info.htm

    4、具体修改:现在就拿品牌页的修改来举例:

    1)  首先是修改数据库,未安装的在数据库结构文件install\data\structure.sql中改,已安装的手动在安装后的数据库中改,对brand表增加brand_title、brand_keywords和brand_description等字段

    2) 接着修改admin\brand.php,这个文件是管理员后台文件

    ·88行:      

        $sql = "INSERT INTO ".$ecs->table('brand')."(brand_name, site_url, brand_desc, brand_logo, is_show, sort_order) "."VALUES ('$_POST[brand_name]', '$site_url', '$_POST[brand_desc]', '$img_name', '$is_show', '$_POST[sort_order]')";
        $db->query($sql);

    改为:  

    $sql = "INSERT INTO ".$ecs->table('brand')."(brand_name, site_url, brand_desc, brand_title, brand_keywords, brand_description,brand_logo, is_show, sort_order) "."VALUES ('$_POST[brand_name]', '$site_url', '$_POST[brand_desc]', '$_POST[brand_title]', '$_POST[brand_keywords]', '$_POST[brand_description]', '$img_name', '$is_show', '$_POST[sort_order]')";
    $db->query($sql);

    ·113行  

    admin_priv('brand_manage');
    $sql = "SELECT brand_id, brand_name, site_url, brand_logo, brand_desc, brand_logo, is_show, sort_order "."FROM " .$ecs->table('brand'). " WHERE brand_id='$_REQUEST[id]'";
    $brand = $db->GetRow($sql);

    改为:  

    admin_priv('brand_manage');
    $sql = "SELECT brand_id, brand_name, site_url, brand_logo, brand_desc,brand_title, brand_keywords, brand_description,brand_logo, is_show, sort_order "."FROM " .$ecs->table('brand'). " WHERE brand_id='$_REQUEST[id]'";
    $brand = $db->GetRow($sql);

    ·151行  

    $img_name = basename($image->upload_image($_FILES['brand_logo'],'brandlogo'));
    $param = "brand_name = '$_POST[brand_name]',  site_url='$site_url', brand_desc='$_POST[brand_desc]', is_show='$is_show', sort_order='$_POST[sort_order]' ";

    改为:  

    $img_name = basename($image->upload_image($_FILES['brand_logo'],'brandlogo'));
    $param = "brand_name = '$_POST[brand_name]',  site_url='$site_url', brand_desc='$_POST[brand_desc]',brand_title='$_POST[brand_title]', brand_keywords='$_POST[brand_keywords]', brand_description='$_POST[brand_description]',is_show='$is_show', sort_order='$_POST[sort_order]' ";

    3)紧接着修改admin\templates\brand_info.htm

    ·在第31行插入:

    <tr>
    <td class="label">页面标题</td>
    <td><input type="text" name="brand_title" maxlength="120" value="{$brand.brand_title|escape}" /></td>
    </tr>
    <tr>
    <td class="label">页面关键词</td>
    <td><input type="text" name="brand_keywords" maxlength="120" value="{$brand.brand_keywords|escape}" /></td>
    </tr>
    <tr>
    <td class="label">页面描述</td>
    <td><textarea  name="brand_description" cols="60" rows="4"  >{$brand.brand_description}</textarea></td>
    </tr>

    4) 最后修改brand.php ,这个文件是前台控制文件

    ·93、94行

    $smarty->assign('keywords',    htmlspecialchars($brand_info['brand_desc']));
    $smarty->assign('description', htmlspecialchars($brand_info['brand_desc']));

    改为:

    $smarty->assign('page_title',    htmlspecialchars($brand_info['brand_title']));
    $smarty->assign('keywords',    htmlspecialchars($brand_info['brand_keywords']));
    $smarty->assign('description', htmlspecialchars($brand_info['brand_description']));

    就这样,品牌页的title,keywords和description全部实现了自定义,商品页、商品分类页、文章页、文章分类页都只需要增加title,修改方法与品牌页(brand)完全相同,想怎么改完全由你自己决定。

    二、修改余下的页面title格式

    1、分析:Ecshop每个页面都包含了商店标题,不利于SE,也不够个性化,前面已将重要的页面修改成有利于SE的,剩下的可以改你自己喜欢的格式,比如:首页格式:商店标题_商店名称;商品名称_分类名称_商店名

    2、修改文件includes\lib_main.php

    3、具体修改:

    ·142行

    $page_title = $GLOBALS['_CFG']['shop_title'] . ' - ' . 'Powered by ECShop';

    改为:

    $page_title = $GLOBALS['_CFG']['shop_name'];

    ·在241行插入:

    if ($filename == 'index')
             $page_title=$GLOBALS['_CFG']['shop_title'] . '_'  . $page_title;

    三、404优化,众所周知,404出错处理不当对搜索引擎收录的影响是非常大的,ecshop在这方面做得非常的差,甚至导致了很多的站不被搜索引擎收录。

    1、分析:ECSHOP程序文件category.php及goods.php等页面多处存在以下这样的代码:ecs_header("Location: ./\n");exit;以上代码的意思是,如果找不到当前ID下的分类或者商品,则跳转到网站首页。这样子跳转,返回的HTTP代码将会是302,表明此页面信息暂时性转移,这类跳转代码很容易引起搜索引擎封杀,因此我们需要作出404的优化。

    2、修改涉及的文件:article.php,article_cat.php,brand.php,category.php,comment.php,goods.php,topic.php

    3、修改方法:将以上7个文件中的 ecs_header("Location: ./\n"); 全部改为 ecs_header("HTTP/1.0 404 Not Found"); $smarty->display('404_error.html');

    同时在模板文件中加入404_error.html文件

    ------------------------------------------华丽丽的分割线--------------------- ------------------------------------

    源厂制造10-10000级洁净无尘车间防静电防尘用品!网址:http://www.lgfjd.com 微信号:614412
  • 相关阅读:
    第六章 优化服务器设置--高性能MySQL 施瓦茨--读书笔记
    skip-external-locking --mysql配置说明
    mysql配置文件my.cnf详解
    Response.Redirect 打开新窗口的两种方法
    .net中Response.End() 和Response.Redirect("http://dotnet.aspx.cc");
    onclientclick与onclick的问题.
    a href="javascript:void(0)" 是什么意思?加不加上有什么区别?
    ashx是什么文件
    CSS里的 no-repeat
    css中 repeat-x 的简单用法
  • 原文地址:https://www.cnblogs.com/wangblognet/p/3020298.html
Copyright © 2011-2022 走看看