静态解决ECshop实现URL重写伪静态和全静态

伪静态  时间:2021-02-08  阅读:()

ECshop 2.7.2实现简单URL重写-伪静态及全静态

*一、找到Ap ac he服务器

1、首先您需要找到 Ap ache安装目录之后找到conf目录下的http d.conf文件。

2、将下面的代码复制到 http d.c onf文件中注意将/ecs hop替换为您的商店的实际

安装目录。

<Directory/ecshop>

Options FollowSymLinks

AllowOverride All

</Direc tory>

3、在http d.conf中搜索Lo adModule rewrit e_mo dule将该行前面的#号删除。如果您的Ap ache是1.3.x版本还需要查找Ad dMo dule mo d_rewrite.c  请将前面的#删除。

4、保存httpd.conf。

5、将ec shop目录下的htacc ess.txt重命名为.htacc ess (windows下用记事本打开然后另存为为.htaccess 。 )

6、重新启动Ap ac he。

7、进入ec shop管理中心->商店设置将URL简单重写设置为启用。

如果您想通过httpd.conf来设置重写规则请按照下面的步骤操作

1、执行上面第1-3步操作。

2、找到您的商店所在的虚拟主机段如

Do cumentRo ot"D:/php/xampp/htdocs"

#

# Each directory to which Apache has access can be configured with respect

# to which services and features are allowed and/or disabled in that

# directory(and its subdirectories).

#

# First,we configure the"default" to be a very restrictive set of

# features.

3、将下面的内容加入在此段代码后面。

<IfMo dule mo d_rewrite.c>

RewriteEngine On

Rewr iteRu le

RewriteRule A(.*)/c ategory$[L] $1/index.php

RewriteRule A(.*)/feed-c([0-9]+).xml$ $1/feed.php?cat=$2 [L]RewriteRule A(.*)/feed-b([0-9]+).xml$ $1/feed.php?bra nd=$2 [L]RewriteRule A(.*)/feed.xml$ $1/feed.php

Rewr iteRu le

A(.*)/category-([0-9]+)-b([0-9]+)-min([0-9]+)-max([0-9]+)-attr([A-]*)-([0-9]+)-(.+)-([a-zA-Z]+)(.*)\.html$$1/category.php?id=$2&brand=$3&pric e_min=$4&pric e_max=$5&filter_attr=$6&p age=$7&s ort=$8&order=$9[QSA,L]Rewr iteRu le

A(.*)/c ategory-([0-9]+)-b([0-9]+)-min([0-9]+)-max([0-9]+)-attr([A-]*)\.html$$1/c ategory.php?id=$2&brand=$3&pric e_min=$4&pric e_max=$5&filter_attr=$6

[QSA,L]

Rewr iteRu le

A(.*)/c ate gory-([0-9]+)-b([0-9]+)-([0-9]+)-(.+)-([a-zA-Z]+)(.*)\.html$$1/c ategory.php?id=$2&brand=$3&p age=$4&s o rt=$5&o rd er=$6[Q S A,L]

A(.*)/category-([0-9]+)-b([0-9]+)-([0-9]+)(.*)\.html$$1/category.php?id=$2&b rand=$3&p age=$4[Q S A,L]RewriteRule

A(.*)/category-([0-9]+)-b([0-9]+)(.*)\.html$

$1/c atego ry.p hp?id=$2&b rand=$3 [Q S A,L]RewriteRule

A(.*)/category-([0-9]+)(.*)\.html$

[QSA,L]

RewriteRule $1/c ategory.php?id=$2A(.*)/goods-([0-9]+)(.*)\.html$

[QSA,L]

RewriteRule $1/go o ds.php?id=$2A(.*)/article_cat-([0-9]+)-([0-9]+)-(.+)-([a-zA-Z]+)(.*)\.html$ &sort

=$4&o rd er=$5[Q S A,L]

RewriteRule $1/artic le_c at.php?id=$2&p age=$3A(.*)/article_cat-([0-9]+)-([0-9]+)(.*)\.html$e=$3 [Q S A,L]RewriteRu le

A(.*)/article_cat-([0-9]+)(.*)\.html$ $1/article_cat.php?id=$2&pag[QSA,L]

RewriteRule

A(.*)/article-([0-9]+)(.*)\.html$ $1/article_cat.php?id=$2

$1/article.php?id=$2Rewr iteRu le

[QSA,L]

RewriteRule A(.*)/brand-([0-9]+)-c([0-9]+)-([0-9]+)-(.+)-([a-zA-Z]+)\.html$1/b rand.p hp?id=$2&c at=$3&p age=$4&s o rt=$5&o rd er=$6[Q S A,L]

RewriteRule A(.*)/brand-([0-9]+)-c([0-9]+)-([0-9]+)(.*)\.html$1/b rand.p hp?id=$2&c at=$3&p age=$4[Q S A,L]

RewriteRule A(.*)/brand-([0-9]+)-c([0-9]+)(.*)\.html$1/b rand.p hp?id=$2&c at=$3 [Q S A,L]

Rewr iteRu le

$1/b rand.p hp?id=$2[Q S A,L]

RewriteRule A($1/s earc h.p hp?keywo rd s=$2[Q S A,L]

Rewr iteRu le

A(.*)/s natch-([0-9]+)\.html$

Rewr iteRu le

A(.*)/group_buy-([0-9]+)\.html$

A(.*)/auc tio n-([0-9]+)\.html$w&id=$2[QSA,L]

</I fMo dule> $1/auc t io n.p hp?ac t=vie

U*)/bra nd-([0-9]+)(.*)\.html

通过这种方法可以实现 EC shop URL简单重写达到伪静态的目的。

ECshop 2.7.2实现简单URL重写-全静态ec s hop生成静态

2010-09-0421:14ec s hop是一个很不错的网店系统现在很多公司都在用它 它本身优化也很好 不过因为是网店很多东西都是动态的所以对优化来说不怎么好不过庆幸的是它可以伪静态。 并且有两种重写方法在后台的商店设置中可以选择简单重写和复杂重写。

伪静态已经基本上可以满足大部分人的需求 如果不满足的还可以根据前面的一篇文章对重写规则进行修改 以满足自己的需求。

但是本文所要描述的是根据EC S HOP内在的一些代码我们生成纯静态的网页使系统更好的优化。在这里我们先对首页进行纯静态生成。

1.复制首页index.php为index_html.php  因为EC S HOP是使用S MARTY模板引擎的所以我们可以使用SMARTY生成文件函数把模板

的静态网页输出。

在首页中 $s marty->dis p lay('ind ex.dwt',$c ac he_id);有这一句说明是把网页显示出来现在我们把它改成如下代码(参看注释)

$file='ind ex.html';//静态网页文件名

$c o ntent=$GLO BALS['s marty']->make_html('index.dwt');//根据index.dwt模板生成网页内容$file name=ROOT_PATH. $file;//静态网页路径file_put_contents($filename,$c ontent);//生成文件

以上几条简单的语句 我们就可以生成首页的静态网页。 同理 我们可以生成产品类别和产品的静态网页整个系统的静态化就完成了。

首页静态页面生成后 我们接下来要生成的是产品类别的静态页面 页面 我的想法是把产品类别

保存在跟目录下这样虽然会比较乱 但是比较适合优化 因为一般搜索引擎抓取的时候只抓取二到三层。把产品类别放在根目录 体现产品类别的重要性易于搜索引擎的抓取另外一方面我们可以把产品放在下个目录中。

类似代码

$filename=build_uri('c ategory',array('c id'=>$c atinfo['c at_id']));// 构造路径这个可以选择自己喜欢的构造方法

$c ontent=$GLOBALS['smarty']->make_html('c ategory.dwt');//产生静态页面内容$filename=ROOT_PATH.$filename;//生成文件路径在根目录下file_put_contents($filename,$c ontent);//输出

产品的静态页面代码

$go o dinfo=get_all_go o ds info($go o ds_id);

$c at_name=$go odinfo['c at_name'];

$go o ds file=build_uri('go o ds',array('gid'=>$go ods_id));

$content=$GLOBALS['smarty']->make_html('goods.dwt');

$html_tempdir=(ROOT_PA TH.$cat_name. '/'); if(!is_dir($html_tempdir))//生成产品目录

{mkdir($html_tempdir);

}

$htmlfilename=ROOT_PATH. $goods file;file_put_contents($htmlfilename,$c ontent);

我的是使用类别名称加下划线 function build_uri( )case'category' :

$c at_name=$GLOBALS['db']->getOne('S ELECT c at_name FROM$GLOBALS['ecs']->table('c ategory') . "WHEREcat_id='$cid'");

$ur i=$c at_name. '-' . $c id;if(!emp ty($p age))

{

$uri .='-' . $p age;

:

$go o ds_info=$GLOBALS['db']->getRow('S ELECT g.goods_name,c.c at_name FROM

$GLOBALS['ecs']->table('goods') . "as g left join" .

$GLOBALS['ecs']->table('category') . "as c on c.cat_id=g.cat_id WHERE g.goods_id='$gid'");$goods_name=$go o ds_info['go ods_name'];

$c at_name=$c at_name;

$ur i=$c at_name. '/' . $good s_name. '-' .$gid;

Sparkedhost($8/月)美国迈阿密AMD Ryzen高性能VPS;免费100G高防

sparkedhost怎么样?sparkedhost主机。Sparkedhost于2017年7月注册在美国康涅狄格州,2018年收购了ClynexHost,2019年8月从Taltum Solutions SL收购了The Beast Hosting,同年10月从Reilly Bauer收购了OptNode Hosting。sparkedhost当前的业务主要为:为游戏“我的世界”提供服务器、虚拟...

vdsina:俄罗斯VPS(datapro),6卢布/天,1G内存/1核(AMD EPYC 7742)/5gNVMe/10T流量

今天获得消息,vdsina上了AMD EPYC系列的VDS,性价比比较高,站长弄了一个,盲猜CPU是AMD EPYC 7B12(经过咨询,详细CPU型号是“EPYC 7742”)。vdsina,俄罗斯公司,2014年开始运作至今,在售卖多类型VPS和独立服务器,可供选择的有俄罗斯莫斯科datapro和荷兰Serverius数据中心。付款比较麻烦:信用卡、webmoney、比特币,不支持PayPal...

GeorgeDatacenter:洛杉矶/达拉斯/芝加哥/纽约vps云服务器;2核/8GB/250GB/2TB流量/1Gbps端口,$84/年

georgedatacenter怎么样?GeorgeDatacenter是一家2017年成立的美国商家,正规注册公司(REG: 10327625611),其实是oneman。现在有优惠,有几款特价VPS,基于Vmware。支持Paypal付款。GeorgeDatacenter目前推出的一款美国vps,2核/8GB内存/250GB NVMe空间/2TB流量/1Gbps端口/Vmware/洛杉矶/达拉...

伪静态为你推荐
绵阳电信绵阳电信宽带套餐资费推荐吴晓波频道买粉《充电时间》的节目跟《吴晓波频道》哪个好听?百度手写百度手写显示镜像文件是什么系统镜像是什么淘宝店推广淘宝店铺推广有哪些渠道?开机滚动条电脑开机有滚动条的画面淘宝网页显示不正常淘宝网显示不正常idc前线永恒之塔内侧 删档吗 ?虚拟机软件下载谁有虚拟机软件的网址要好用的宽带接入服务器网络已连接,可无法连接到服务器为什么?网络已连接,可无法连接到服务
国外服务器网站 wordpress技巧 免费网站监控 ssh帐号 免费吧 服务器托管什么意思 支付宝扫码领红包 789电视剧 新世界服务器 谷歌台湾 深圳域名 免费稳定空间 七牛云存储 建站技术 cx域名 wannacry勒索病毒 卡巴斯基免费版 vim 装修瓦工招聘 免费邮件服务器软件 更多