完成ecshop自定义目录结构伪静态url

2016-07-07 14:55 来源:www.chinab4c.com 作者:ecshop专家

ecshop自定义目录结构伪静态url,这个功能是非常多的人想要的,其实很简单,。就是在ecshop后台商品编辑录入的时候。或者是ecshop商品分类录入编辑的时候,可以自定义目录结构,让自己的商品地址url以及分类地址url看上去,更加的个性化。下面我们将结合ecshop的数据库处理以及php程序处理,来完成ecshop自定义目录结构伪静态url。
1:修改ecshop商品表ecs_goods,ecs_category的 ecshop数据库结构,增加url 字段
alter table ecs_goods add column url varchar(128) not null default '';
alter table ecs_category add column url varchar(128) not null default '';
2:admin/goods.php修改以下代码
$sql = "INSERT INTO " . $ecs->table('goods') . " (goods_name, goods_name_style, goods_sn, " .
"cat_id, brand_id, shop_price, market_price, is_promote, promote_price, " .
"promote_start_date, promote_end_date, goods_img, goods_thumb, original_img, keywords, goods_brief, " .
"seller_note, goods_weight, goods_number, warn_number, integral, give_integral, is_best, is_new, is_hot, " .
"is_on_sale, is_alone_sale, is_shipping, goods_desc, add_time, last_update, goods_type, rank_integral, suppliers_id,url)" .
"VALUES ('$_POST[goods_name]', '$goods_name_style', '$goods_sn', '$catgory_id', " .
"'$brand_id', '$shop_price', '$market_price', '$is_promote','$promote_price', ".
"'$promote_start_date', '$promote_end_date', '$goods_img', '$goods_thumb', '$original_img', ".
"'$_POST[keywords]', '$_POST[goods_brief]', '$_POST[seller_note]', '$goods_weight', '$goods_number',".
" '$warn_number', '$_POST[integral]', '$give_integral', '$is_best', '$is_new', '$is_hot', '$is_on_sale', '$is_alone_sale', $is_shipping, ".
" '$_POST[goods_desc]', '" . gmtime() . "', '". gmtime() ."', '$goods_type', '$rank_integral', '$suppliers_id','$_POST[url]')";

3:admin/category.php修改以下代码
$cat['url'] = !empty($_POST['url']) ? trim($_POST['url']) : '';
4:调整url规则,以下是apache下面的规则
RewriteRule ^(.*?)\/([0-9]+)-b([0-9]+)-min([0-9]+)-max([0-9]+)-attr([^-]*)-([0-9]+)-(.+)-([a-zA-Z]+)(.*)\.html$category\.php\?id=$2&brand=$3&price_min=$4&price_max=$5&filter_attr=$6&page=$7&sort=$8&order=$9 [QSA,L]
RewriteRule ^(.*?)\/([0-9]+)-b([0-9]+)-min([0-9]+)-max([0-9]+)-attr([^-]*)(.*)\.html$ category\.php\?id=$2&brand=$3&price_min=$4&price_max=$5&filter_attr=$6 [QSA,L]
RewriteRule ^(.*?)\/([0-9]+)-b([0-9]+)-([0-9]+)-(.+)-([a-zA-Z]+)(.*)\.html$category\.php\?id=$2&brand=$3&page=$4&sort=$5&order=$6 [QSA,L]
RewriteRule ^(.*?)\/([0-9]+)-b([0-9]+)-([0-9]+)(.*)\.html$ category\.php\?id=$2&brand=$3&page=$4[QSA,L]
RewriteRule ^(.*?)\/([0-9]+)-b([0-9]+)(.*)\.html$ category\.php\?id=$2&brand=$3[QSA,L]
RewriteRule ^(.*?)\/([0-9]+)(.*)\.html$category\.php\?id=$2[QSA,L]
hongbsyu181.com
haiwxyu891.com
yonglech561.com
wangziylc891.com
baiheyle691.com

RewriteRule ^(.*?)\/([0-9]+)$goods\.php\?id=$2 [QSA,L]