ECShop网店系统技术交流论坛's Archiver

ljl88 发表于 2010-6-20 19:23

ecshop2.7.2完全静态化方案V1.1

[i=s] 本帖最后由 ljl88 于 2010-7-11 23:13 编辑 [/i]

[size=5][color=#000000][font=Arial]Ecshop[/font][font=黑体]([/font][font=Arial]v2.7.2 UTF8 RELEASE 20100604[/font][font=黑体])静态化方案[/font][font=Arial]V1.1[/font][/color][/size][p=30, 2, left][b][color=#000000][font=宋体]一、静态化原因[/font][/color][/b][/p][p=30, 2, left][color=#000000][font=Times New Roman]Ecshop[/font][font=宋体]提供的伪静态化方案,利用[/font][font=Times New Roman]URL[/font][font=宋体]重写,将[/font][font=Times New Roman]html[/font][font=宋体]映射到[/font][font=Times New Roman]php[/font][font=宋体]上,只是一种[/font][font=Times New Roman]SEO[/font][font=宋体]优化方法,最终执行的还是[/font][font=Times New Roman]php[/font][font=宋体],并不能提高系统的性能。[/font][/color][/p][p=30, 2, left][font=Times New Roman][color=#000000] [/color][/font][/p][p=30, 2, left][b][color=#000000][font=宋体]二、静态化思路[/font][/color][/b][/p][p=30, 2, left][font=Times New Roman][color=#000000]1、
[/color][/font][color=#000000][font=宋体]仍然利用[/font][font=Times New Roman]URL[/font][font=宋体]重写,将[/font][font=Times New Roman]html[/font][font=宋体]映射到[/font][font=Times New Roman]php[/font][font=宋体]上。但在每次访问时,都先通过[/font][font=Times New Roman]apache url rewrite[/font][font=宋体]规则判断静态页面是否存在,如果不存在,则访问[/font][font=Times New Roman]php[/font][font=宋体],并生成相应的[/font][font=Times New Roman]html[/font][font=宋体]页面;如果存在,则直接访问静态页面。[/font][/color][/p][p=30, 2, left][font=Times New Roman][color=#000000]2、
[/color][/font][color=#000000][font=宋体]如果[/font][font=Times New Roman]php[/font][font=宋体]文件或者页面内容作了修改,则只需要删除静态页面即可,在用户下次访问时,即可自动重新生成静态页面。[/font][/color][/p][p=30, 2, left][font=Times New Roman][color=#000000]3、
[/color][/font][color=#000000][font=宋体]对于页面中动态更新的部分需要进行单独处理,比如用户登录的状态、浏览历史、购物车信息等。在此方案中,采用了[/font][font=Times New Roman]javascript[/font][font=宋体]动态调用方法,对部分程序进行了修改。[/font][/color][/p][p=30, 2, left][font=Times New Roman][color=#000000]4、
[/color][/font][font=宋体][color=#000000]主要针对首页、频道页、产品分类页、产品页、文章列表页、文章页等页面进行静态化。对于完全动态的页面,比如用户中心、搜索结果页面,则不做静态化处理。[/color][/font][/p][p=30, 2, left][font=Times New Roman][color=#000000] [/color][/font][/p][p=30, 2, left][b][color=#000000][font=宋体]三、此方案的优缺点[/font][/color][/b][/p][p=30, 2, left][b][color=#000000][font=宋体]优点:[/font][/color][/b][/p][p=30, 2, left][color=#000000][font=Times New Roman]1[/font][font=宋体]、实现了真正的静态化;[/font][/color][/p][p=30, 2, left][color=#000000][font=Times New Roman]2[/font][font=宋体]、通过用户首次访问生成静态页面,不需要后台去统一生成;[/font][/color][/p][p=30, 2, left][color=#000000][font=Times New Roman]3[/font][font=宋体]、网页内容更新后,系统会根据操作记录去删除已经更新的静态页面。操作记录使用[/font][font=Times New Roman]mysql[/font][font=宋体]触发器来实现,用户可以根据需要自己修改。[/font][/color][/p][p=30, 2, left][color=#000000][font=Times New Roman]4[/font][font=宋体]、如果用户修改了网站结构,可以选择删除全部静态页面。当用户访问时,即可重新生成。[/font][/color][/p][p=30, 2, left][font=Times New Roman][color=#000000] [/color][/font][/p][p=30, 2, left][b][color=#000000][font=宋体]缺点:[/font][/color][/b][/p][p=30, 2, left][color=#000000][font=Times New Roman]1[/font][font=宋体]、方案只是针对[/font][font=Times New Roman]ecshop[/font][font=宋体]的默认模板页进行静态化处理,如果用户用的不是默认模板页,则可以参照以下的修改方法,自己去修改。[/font][/color][/p][p=30, 2, left][color=#000000][font=Times New Roman]2[/font][font=宋体]、此方案比较复杂,用户需要懂得一些[/font][font=Times New Roman]apache[/font][font=宋体]脚本、[/font][font=Times New Roman]sql[/font][font=宋体]语言和[/font][font=Times New Roman]php[/font][font=宋体]编程方面知识。[/font][/color][/p][p=30, 2, left][font=Times New Roman][color=#000000] [/color][/font][/p][p=30, 2, left][b][color=#000000][font=宋体]四、静态化方案详解[/font][/color][/b][/p][p=30, 2, left][color=#000000][font=宋体]此次静态化修改的[/font][font=Times New Roman]Ecshop[/font][font=宋体]版本为[/font][font=Times New Roman]v2.7.2 UTF8 RELEASE 20100604[/font][font=宋体],增加或者修改的文件见下载附件。[/font][/color][/p][p=30, 2, left][color=#000000][font=宋体](一)、[/font][font=Times New Roman]URL[/font][font=宋体]重写脚本[/font][/color][/p][p=30, 2, left][color=#000000][font=宋体]如果使用[/font][font=Times New Roman]htaccess[/font][font=宋体]方式,见《[/font][font=Times New Roman]htaccess.txt[/font][font=宋体]》;如果是通过[/font][font=Times New Roman] httpd.conf [/font][font=宋体]来设置重写规则,见《[/font][font=Times New Roman]httpd.txt[/font][font=宋体]》文件。[/font][/color][/p][p=30, 2, left][font=Times New Roman][color=#000000] [/color][/font][/p][p=30, 2, left][color=#000000][font=宋体](二)、[/font][font=Times New Roman]mysql[/font][font=宋体]脚本[/font][/color][/p][p=30, 2, left][color=#000000][font=宋体]见《[/font][font=Times New Roman]static.sql[/font][font=宋体]》文件,用于记录页面内容的更新操作(包括增删改),系统再根据这些操作记录去删除相应的静态页面。新增了表[/font][font=Times New Roman]yak_delstatic_log[/font][font=宋体]和[/font][font=Times New Roman]yak_delstatic_check[/font][font=宋体]。其中[/font][font=Times New Roman]yak_delstatic_log[/font][font=宋体]用于保存数据的修改记录,表[/font][font=Times New Roman]yak_delstatic_check[/font][font=宋体]用于保存活动起止的检查记录。[/font][/color][/p][p=30, 2, left][font=Times New Roman][color=#000000] [/color][/font][/p][p=30, 2, left][font=宋体][color=#000000](三)、修改或者增加的文件说明[/color][/font][/p][p=30, 2, left][color=#000000][font=宋体]见《版本历史[/font][font=Times New Roman].doc[/font][font=宋体]》文件。[/font][/color][/p][p=30, 2, left][font=Times New Roman][color=#000000] [/color][/font][/p][p=30, 2, left][b][color=#000000][font=宋体]五、静态化操作步骤[/font][/color][/b][/p][p=30, 2, left][color=#000000][font=Times New Roman]1[/font][font=宋体]、首先需要确认[/font][font=Times New Roman]Ecshop[/font][font=宋体]版本为[/font][font=Times New Roman]v2.7.2 UTF8 RELEASE 20100604[/font][font=宋体],模板为默认模板。如果版本或者模板不一致,则需要参考这个方案自己修改。[/font][/color][/p][p=30, 2, left][color=#000000][font=Times New Roman]2[/font][font=宋体]、在根目录下新建[/font][font=Times New Roman]html[/font][font=宋体]文件目录,并确认可以写入。[/font][/color][/p][p=30, 2, left][color=#000000][font=Times New Roman]3[/font][font=宋体]、确认[/font][font=Times New Roman]data[/font][font=宋体]目录可以写入。当执行删除已更新的静态页面操作时需要在[/font][font=Times New Roman]data[/font][font=宋体]目录下保存数据。[/font][/color][/p][p=30, 2, left][color=#000000][font=Times New Roman]4[/font][font=宋体]、运行[/font][font=Times New Roman]static.sql[/font][font=宋体]脚本。首先打开[/font][font=Times New Roman]static.sql[/font][font=宋体],将[/font][font=Times New Roman]ecs[/font][font=宋体]前缀改成和当前的一致,然后将[/font][font=Times New Roman]static.sql[/font][font=宋体]上传到服务器上,在[/font][font=Times New Roman]mysql[/font][font=宋体]的终端模式下,执行命令:[/font][font=Times New Roman]use <database[/font][font=宋体]名称[/font][font=Times New Roman]>;source <[/font][font=宋体]路径[/font][font=Times New Roman]>/static.sql;[/font][/color][font=宋体][color=#000000]。[/color][color=red]注意,在[/color][/font][color=red][font=Times New Roman]phpmyadmin[/font][/color][color=red][font=宋体]下执行没有测试过,可能会报错。[/font][/color][/p][p=30, 2, left][color=#000000][font=Times New Roman]5[/font][font=宋体]、用下载的[/font][font=Times New Roman]php[/font][font=宋体]文件覆盖当前的文件,覆盖前请先做好备份。[/font][/color][/p][p=30, 2, left][color=#000000][font=Times New Roman]6[/font][font=宋体]、开启后台的[/font][font=Times New Roman]URL[/font][/color][color=red][font=宋体]简单重写[/font][/color][color=#000000][font=宋体]功能,并修改[/font][font=Times New Roman]URL[/font][font=宋体]重写规则。重写规则分别有[/font][font=Times New Roman]htaccess[/font][font=宋体]和[/font][font=Times New Roman]httpd.conf[/font][font=宋体]两种方式。如果使用[/font][font=Times New Roman]htaccess[/font][font=宋体]方式,请将[/font][font=Times New Roman]httpd.conf[/font][font=宋体]中的[/font][font=Times New Roman]AllowOverride[/font][font=宋体]设置为[/font][font=Times New Roman]All[/font][font=宋体]。如果修改了[/font][font=Times New Roman]httpd.conf[/font][font=宋体]需要重启[/font][font=Times New Roman]apache[/font][font=宋体]。[/font][/color][/p][p=30, 2, left][color=#000000][font=Times New Roman]7[/font][font=宋体]、打开管理后台的计划任务,安装“删除静态页面”的计划任务,并开启。可将计划任务执行时间设置为[/font][font=Times New Roman]10[/font][font=宋体]分钟,这样每隔[/font][font=Times New Roman]10[/font][font=宋体]分钟系统就会自动检查更新的记录,删除内容已经更新的页面。也可以在每次修改了后台数据后,点击后台右上角的“删除更新静态”,立刻执行检查修改。[/font][/color][/p][p=30, 2, left][font=Times New Roman][color=#000000] [/color][/font][/p][p=30, 2, left][b][font=宋体][size=14pt][color=#000000]测试地址:[/color][/size][/font][/b][font=Times New Roman][b][u][size=14pt]http://ecshop.uckaka.com[/size][/u][/b]
[/font][color=#000000][font=宋体][size=14pt]联系[/size][/font][size=14pt][font=Times New Roman]EMAIL[/font][/size][font=宋体][size=14pt]:[/size][/font][size=14pt][font=Times New Roman][url=mailto:ljl88@sina.com]ljl88@sina.com[/url] 下载:[attach]38235[/attach][/font][/size][/color][/p]

hemingxun 发表于 2010-6-21 11:23

这个真的是太棒了 。

wangkuai 发表于 2010-6-21 13:51

静态化 很重要的说

qiudongcao 发表于 2010-6-21 14:30

坚决顶起来,这个很实用
一直在期待官方出方案来着
~~

atibey 发表于 2010-6-21 15:26

和系统自动的重写有什么区别

leon358 发表于 2010-6-21 16:59

支持下,虽然还不明白

137147530 发表于 2010-6-21 17:16

感谢了测试一下,希望能用,那就太棒了

小无名 发表于 2010-6-22 09:45

**** 作者被禁止或删除 内容自动屏蔽 ****

ljl88 发表于 2010-6-22 11:01

更新了一下下载包,更正了一些错误。
1、底部系统执行信息改为动态显示。
2、修改了文章列表搜索静态化无法使用的错误。
3、修改了goods.php页面ajax调用返回的一个错误。

ljl88 发表于 2010-6-22 11:16

[i=s] 本帖最后由 ljl88 于 2010-7-11 23:41 编辑 [/i]

[color=blue]ECSHOP官方提供的静态化实际上是伪静态,只是做了一下URL重写,把HTML转成对应的PHP,这样用户每次访问,还是要执行PHP。做伪静态,可以更容易被搜索引擎搜录,也就是通常说的SEO优化方法。
我的思路也是基于URL重写,但会判断真实的HTML是否存在,如果不存在,则还是访问PHP,但同时生成HTML。这样以后用户再次访问,就访问的是真实的HTML,而不是PHP了。如果内容更新了,只要删除HTML,下次用户再访问,自己就会重新再生成新的。[/color]
[color=blue]apache的URL重写,使用htaccess和httpd.conf的是有差别的,以下是分别是两个版本的URL重写脚本。[/color]

[color=red][b]htaccess版本:[/b][/color]
[code]
<FilesMatch "\.(bak|inc|lib|sh|tpl|lbi|dwt)$">
    order deny,allow
    deny from all
</FilesMatch>
RewriteEngine On
RewriteBase /
RewriteRule ^$                          index.html [L,R]
RewriteRule ^category$                  index.html [L,R]
RewriteRule ^message.html$              message-1.html [L,R]
   
RewriteCond %{REQUEST_URI} ^/index.html$ [OR]
RewriteCond %{REQUEST_URI} ^/snatch.html$ [OR]
RewriteCond %{REQUEST_URI} ^/group_buy.html$ [OR]
RewriteCond %{REQUEST_URI} ^/auction.html$ [OR]
RewriteCond %{REQUEST_URI} ^/exchange.html$ [OR]
RewriteCond %{REQUEST_URI} ^/activity.html$ [OR]
#RewriteCond %{REQUEST_URI} ^/feed-c([0-9]+).xml$ [OR]
#RewriteCond %{REQUEST_URI} ^/feed-b([0-9]+).xml$ [OR]
#RewriteCond %{REQUEST_URI} ^/feed-type([^-]+)\.xml$ [OR]
#RewriteCond %{REQUEST_URI} ^/feed.xml$ [OR]
RewriteCond %{REQUEST_URI} ^/category-([0-9]+)-b([0-9]+)-min([0-9]+)-max([0-9]+)-attr([^-]*)-([0-9]+)-(.+)-([a-zA-Z]+)(.*)\.html$ [OR]
RewriteCond %{REQUEST_URI} ^/category-([0-9]+)-b([0-9]+)-min([0-9]+)-max([0-9]+)-attr([^-]*)(.*)\.html$ [OR]
RewriteCond %{REQUEST_URI} ^/category-([0-9]+)-b([0-9]+)-([0-9]+)-(.+)-([a-zA-Z]+)(.*)\.html$ [OR]
RewriteCond %{REQUEST_URI} ^/category-([0-9]+)-b([0-9]+)-([0-9]+)(.*)\.html$ [OR]
RewriteCond %{REQUEST_URI} ^/category-([0-9]+)-b([0-9]+)(.*)\.html$ [OR]
RewriteCond %{REQUEST_URI} ^/category-([0-9]+)(.*)\.html$ [OR]
RewriteCond %{REQUEST_URI} ^/goods-([0-9]+)(.*)\.html$ [OR]
RewriteCond %{REQUEST_URI} ^/article_cat-([0-9]+)-([0-9]+)-(.+)-([a-zA-Z]+)(.*)\.html$ [OR]
RewriteCond %{REQUEST_URI} ^/article_cat-([0-9]+)-([0-9]+)-(.+)(.*)\.html$ [OR]
RewriteCond %{REQUEST_URI} ^/article_cat-([0-9]+)-([0-9]+)(.*)\.html$ [OR]
RewriteCond %{REQUEST_URI} ^/article_cat-([0-9]+)(.*)\.html$ [OR]
RewriteCond %{REQUEST_URI} ^/article-([0-9]+)(.*)\.html$ [OR]
RewriteCond %{REQUEST_URI} ^/brand-([0-9]+)-c([0-9]+)-([0-9]+)-(.+)-([a-zA-Z]+)\.html [OR]
RewriteCond %{REQUEST_URI} ^/brand-([0-9]+)-c([0-9]+)-([0-9]+)(.*)\.html [OR]
RewriteCond %{REQUEST_URI} ^/brand-([0-9]+)-c([0-9]+)(.*)\.html [OR]
RewriteCond %{REQUEST_URI} ^/brand-([0-9]+)(.*)\.html [OR]
#RewriteCond %{REQUEST_URI} ^/tag-(.*)\.html [OR]
#RewriteCond %{REQUEST_URI} ^/snatch-([0-9]+)\.html$ [OR]
RewriteCond %{REQUEST_URI} ^/group_buy-([0-9]+)\.html$ [OR]
#RewriteCond %{REQUEST_URI} ^/auction-([0-9]+)\.html$ [OR]
RewriteCond %{REQUEST_URI} ^/exchange-id([0-9]+)(.*)\.html$ [OR]
RewriteCond %{REQUEST_URI} ^/exchange-([0-9]+)-min([0-9]+)-max([0-9]+)-([0-9]+)-(.+)-([a-zA-Z]+)(.*)\.html$ [OR]
RewriteCond %{REQUEST_URI} ^/exchange-([0-9]+)-([0-9]+)-(.+)-([a-zA-Z]+)(.*)\.html$ [OR]
RewriteCond %{REQUEST_URI} ^/exchange-([0-9]+)-([0-9]+)(.*)\.html$ [OR]
RewriteCond %{REQUEST_URI} ^/exchange-([0-9]+)(.*)\.html$ [OR]
RewriteCond %{REQUEST_URI} ^/message-([0-9]+)(.*)\.html$
RewriteCond %{DOCUMENT_ROOT}/html/%{REQUEST_URI} -f
RewriteRule ^(.+) html/$1 [L]
# direct one-word access
RewriteRule ^index.html$                index\.php                       [L]   
RewriteRule ^snatch.html$               snatch\.php                      [L]  
RewriteRule ^group_buy.html$            group_buy\.php                   [L]  
RewriteRule ^auction.html$              auction\.php                     [L]  
RewriteRule ^exchange.html$             exchange\.php                    [L]  
RewriteRule ^activity.html$             activity\.php                    [L]
# access any object by its numeric identifier
RewriteRule ^feed-c([0-9]+)\.xml$       feed\.php\?cat=$1 [L]
RewriteRule ^feed-b([0-9]+)\.xml$       feed\.php\?brand=$1 [L]
RewriteRule ^feed-type([^-]+)\.xml$       feed\.php\?type=$1 [L]
RewriteRule ^feed\.xml$                 feed\.php [L]
RewriteRule ^category-([0-9]+)-b([0-9]+)-min([0-9]+)-max([0-9]+)-attr([^-]*)-([0-9]+)-(.+)-([a-zA-Z]+)(.*)\.html$  category\.php\?id=$1&brand=$2&price_min=$3&price_max=$4&filter_attr=$5&page=$6&sort=$7&order=$8 [QSA,L]
RewriteRule ^category-([0-9]+)-b([0-9]+)-min([0-9]+)-max([0-9]+)-attr([^-]*)(.*)\.html$                            category\.php\?id=$1&brand=$2&price_min=$3&price_max=$4&filter_attr=$5 [QSA,L]
RewriteRule ^category-([0-9]+)-b([0-9]+)-([0-9]+)-(.+)-([a-zA-Z]+)(.*)\.html$                                      category\.php\?id=$1&brand=$2&page=$3&sort=$4&order=$5 [QSA,L]
RewriteRule ^category-([0-9]+)-b([0-9]+)-([0-9]+)(.*)\.html$                                                       category\.php\?id=$1&brand=$2&page=$3  [QSA,L]
RewriteRule ^category-([0-9]+)-b([0-9]+)(.*)\.html$                                                                category\.php\?id=$1&brand=$2  [QSA,L]
RewriteRule ^category-([0-9]+)(.*)\.html$                                                                          category\.php\?id=$1  [QSA,L]
RewriteRule ^goods-([0-9]+)(.*)\.html$  goods\.php\?id=$1 [QSA,L]
RewriteRule ^article_cat-([0-9]+)-([0-9]+)-(.+)-([a-zA-Z]+)(.*)\.html$  article_cat\.php\?id=$1&page=$2&sort=$3&order=$4  [QSA,L]
RewriteRule ^article_cat-([0-9]+)-([0-9]+)-(.+)(.*)\.html$              article_cat\.php\?id=$1&page=$2&keywords=$3 [QSA,L]
RewriteRule ^article_cat-([0-9]+)-([0-9]+)(.*)\.html$                   article_cat\.php\?id=$1&page=$2   [QSA,L]
RewriteRule ^article_cat-([0-9]+)(.*)\.html$                            article_cat\.php\?id=$1   [QSA,L]
RewriteRule ^article-([0-9]+)(.*)\.html$                                article\.php\?id=$1   [QSA,L]
RewriteRule ^brand-([0-9]+)-c([0-9]+)-([0-9]+)-(.+)-([a-zA-Z]+)\.html   brand\.php\?id=$1&cat=$2&page=$3&sort=$4&order=$5 [QSA,L]
RewriteRule ^brand-([0-9]+)-c([0-9]+)-([0-9]+)(.*)\.html                brand\.php\?id=$1&cat=$2&page=$3 [QSA,L]
RewriteRule ^brand-([0-9]+)-c([0-9]+)(.*)\.html                         brand\.php\?id=$1&cat=$2 [QSA,L]
RewriteRule ^brand-([0-9]+)(.*)\.html                                   brand\.php\?id=$1 [QSA,L]
RewriteRule ^tag-(.*)\.html                                             search\.php\?keywords=$1&notstatic=1 [QSA,L]
RewriteRule ^snatch-([0-9]+)\.html$                                     snatch\.php\?id=$1&notstatic=1 [QSA,L]
RewriteRule ^group_buy-([0-9]+)\.html$                                  group_buy\.php\?act=view&id=$1 [QSA,L]
RewriteRule ^auction-([0-9]+)\.html$                                    auction\.php\?act=view&id=$1&notstatic=1 [QSA,L]
RewriteRule ^exchange-id([0-9]+)(.*)\.html$                             exchange\.php\?id=$1&act=view [QSA,L]
RewriteRule ^exchange-([0-9]+)-min([0-9]+)-max([0-9]+)-([0-9]+)-(.+)-([a-zA-Z]+)(.*)\.html$ exchange\.php\?cat_id=$1&integral_min=$2&integral_max=$3&page=$4&sort=$5&order=$6 [QSA,L]
RewriteRule ^exchange-([0-9]+)-([0-9]+)-(.+)-([a-zA-Z]+)(.*)\.html$                         exchange\.php\?cat_id=$1&page=$2&sort=$3&order=$4 [QSA,L]
RewriteRule ^exchange-([0-9]+)-([0-9]+)(.*)\.html$                                          exchange\.php\?cat_id=$1&page=$2  [QSA,L]
RewriteRule ^exchange-([0-9]+)(.*)\.html$                                                   exchange\.php\?cat_id=$1  [QSA,L]
RewriteRule ^message-([0-9]+)(.*)\.html$                                 message\.php\?page=$1 [QSA,L]
[/code]

gezi_hui 发表于 2010-6-22 11:18

这个插件我也有,,没想共享出来了

ljl88 发表于 2010-6-22 11:22

[i=s] 本帖最后由 ljl88 于 2010-7-11 23:42 编辑 [/i]

[color=red][b]httpd.conf版本[/b][/color]
[code]
    <IfModule mod_rewrite.c>
    RewriteEngine On
  
    RewriteRule ^(.*)/$                          $1/index.html [L,R]
    RewriteRule ^(.*)/category$                  $1/index.html [L,R]
    RewriteRule ^(.*)/message.html$              $1/message-1.html [L,R]
   
    RewriteCond %{REQUEST_FILENAME} index.html$ [OR]
    RewriteCond %{REQUEST_FILENAME} snatch.html$ [OR]
    RewriteCond %{REQUEST_FILENAME} group_buy.html$ [OR]
    RewriteCond %{REQUEST_FILENAME} auction.html$ [OR]
    RewriteCond %{REQUEST_FILENAME} exchange.html$ [OR]
    RewriteCond %{REQUEST_FILENAME} activity.html$ [OR]
    #RewriteCond %{REQUEST_FILENAME} feed-c([0-9]+).xml$ [OR]
    #RewriteCond %{REQUEST_FILENAME} feed-b([0-9]+).xml$ [OR]
    #RewriteCond %{REQUEST_FILENAME} feed-type([^-]+)\.xml$ [OR]
    #RewriteCond %{REQUEST_FILENAME} feed.xml$ [OR]
    RewriteCond %{REQUEST_FILENAME} category-([0-9]+)-b([0-9]+)-min([0-9]+)-max([0-9]+)-attr([^-]*)-([0-9]+)-(.+)-([a-zA-Z]+)(.*)\.html$ [OR]
    RewriteCond %{REQUEST_FILENAME} category-([0-9]+)-b([0-9]+)-min([0-9]+)-max([0-9]+)-attr([^-]*)(.*)\.html$ [OR]
    RewriteCond %{REQUEST_FILENAME} category-([0-9]+)-b([0-9]+)-([0-9]+)-(.+)-([a-zA-Z]+)(.*)\.html$ [OR]
    RewriteCond %{REQUEST_FILENAME} category-([0-9]+)-b([0-9]+)-([0-9]+)(.*)\.html$ [OR]
    RewriteCond %{REQUEST_FILENAME} category-([0-9]+)-b([0-9]+)(.*)\.html$ [OR]
    RewriteCond %{REQUEST_FILENAME} category-([0-9]+)(.*)\.html$ [OR]
    RewriteCond %{REQUEST_FILENAME} goods-([0-9]+)(.*)\.html$ [OR]
    RewriteCond %{REQUEST_FILENAME} article_cat-([0-9]+)-([0-9]+)-(.+)-([a-zA-Z]+)(.*)\.html$ [OR]
    RewriteCond %{REQUEST_FILENAME} article_cat-([0-9]+)-([0-9]+)-(.+)(.*)\.html$ [OR]
    RewriteCond %{REQUEST_FILENAME} article_cat-([0-9]+)-([0-9]+)(.*)\.html$ [OR]
    RewriteCond %{REQUEST_FILENAME} article_cat-([0-9]+)(.*)\.html$ [OR]
    RewriteCond %{REQUEST_FILENAME} article-([0-9]+)(.*)\.html$ [OR]
    RewriteCond %{REQUEST_FILENAME} brand-([0-9]+)-c([0-9]+)-([0-9]+)-(.+)-([a-zA-Z]+)\.html [OR]
    RewriteCond %{REQUEST_FILENAME} brand-([0-9]+)-c([0-9]+)-([0-9]+)(.*)\.html [OR]
    RewriteCond %{REQUEST_FILENAME} brand-([0-9]+)-c([0-9]+)(.*)\.html [OR]
    RewriteCond %{REQUEST_FILENAME} brand-([0-9]+)(.*)\.html [OR]
    #RewriteCond %{REQUEST_FILENAME} tag-(.*)\.html [OR]
    #RewriteCond %{REQUEST_FILENAME} snatch-([0-9]+)\.html$ [OR]
    RewriteCond %{REQUEST_FILENAME} group_buy-([0-9]+)\.html$ [OR]
    #RewriteCond %{REQUEST_FILENAME} auction-([0-9]+)\.html$ [OR]
    RewriteCond %{REQUEST_FILENAME} exchange-id([0-9]+)(.*)\.html$ [OR]
    RewriteCond %{REQUEST_FILENAME} exchange-([0-9]+)-min([0-9]+)-max([0-9]+)-([0-9]+)-(.+)-([a-zA-Z]+)(.*)\.html$ [OR]
    RewriteCond %{REQUEST_FILENAME} exchange-([0-9]+)-([0-9]+)-(.+)-([a-zA-Z]+)(.*)\.html$ [OR]
    RewriteCond %{REQUEST_FILENAME} exchange-([0-9]+)-([0-9]+)(.*)\.html$ [OR]
    RewriteCond %{REQUEST_FILENAME} exchange-([0-9]+)(.*)\.html$ [OR]
    RewriteCond %{REQUEST_FILENAME} message-([0-9]+)(.*)\.html$
    RewriteCond %{DOCUMENT_ROOT}/html/%{REQUEST_FILENAME} -f
    RewriteRule ^/(.+) /html/$1 [L]
   
    RewriteRule ^(.*)/index.html$                $1/index.php                       [L]   
    RewriteRule ^(.*)/snatch.html$               $1/snatch.php                      [L]  
    RewriteRule ^(.*)/group_buy.html$            $1/group_buy.php                   [L]  
    RewriteRule ^(.*)/auction.html$              $1/auction.php                     [L]  
    RewriteRule ^(.*)/exchange.html$             $1/exchange.php                    [L]  
    RewriteRule ^(.*)/activity.html$             $1/activity.php                    [L]
    RewriteRule ^(.*)/feed-c([0-9]+).xml$        $1/feed.php?cat=$2                 [L]
    RewriteRule ^(.*)/feed-b([0-9]+).xml$        $1/feed.php?brand=$2               [L]
    RewriteRule ^(.*)/feed-type([^-]+)\.xml$     $1/feed\.php\?type=$2              [L]
    RewriteRule ^(.*)/feed.xml$                  $1/feed.php                        [L]
    RewriteRule ^(.*)/category-([0-9]+)-b([0-9]+)-min([0-9]+)-max([0-9]+)-attr([^-]*)-([0-9]+)-(.+)-([a-zA-Z]+)(.*)\.html$  $1/category.php?id=$2&brand=$3&price_min=$4&price_max=$5&filter_attr=$6&page=$7&sort=$8&order=$9 [QSA,L]
    RewriteRule ^(.*)/category-([0-9]+)-b([0-9]+)-min([0-9]+)-max([0-9]+)-attr([^-]*)(.*)\.html$                            $1/category.php?id=$2&brand=$3&price_min=$4&price_max=$5&filter_attr=$6 [QSA,L]
    RewriteRule ^(.*)/category-([0-9]+)-b([0-9]+)-([0-9]+)-(.+)-([a-zA-Z]+)(.*)\.html$                              $1/category.php?id=$2&brand=$3&page=$4&sort=$5&order=$6 [QSA,L]
    RewriteRule ^(.*)/category-([0-9]+)-b([0-9]+)-([0-9]+)(.*)\.html$                                       $1/category.php?id=$2&brand=$3&page=$4 [QSA,L]
    RewriteRule ^(.*)/category-([0-9]+)-b([0-9]+)(.*)\.html$                                            $1/category.php?id=$2&brand=$3 [QSA,L]
    RewriteRule ^(.*)/category-([0-9]+)(.*)\.html$                               $1/category.php?id=$2 [QSA,L]
    RewriteRule ^(.*)/goods-([0-9]+)(.*)\.html$                                  $1/goods.php?id=$2 [QSA,L]
    RewriteRule ^(.*)/article_cat-([0-9]+)-([0-9]+)-(.+)-([a-zA-Z]+)(.*)\.html$  $1/article_cat.php?id=$2&page=$3&sort=$4&order=$5 [QSA,L]
    RewriteRule ^(.*)/article_cat-([0-9]+)-([0-9]+)-(.+)(.*)\.html$              $1/article_cat\.php\?id=$1&page=$2&keywords=$3 [QSA,L]
    RewriteRule ^(.*)/article_cat-([0-9]+)-([0-9]+)(.*)\.html$                   $1/article_cat.php?id=$2&page=$3 [QSA,L]
    RewriteRule ^(.*)/article_cat-([0-9]+)(.*)\.html$                            $1/article_cat.php?id=$2 [QSA,L]
    RewriteRule ^(.*)/article-([0-9]+)(.*)\.html$                                $1/article.php?id=$2 [QSA,L]
    RewriteRule ^(.*)/brand-([0-9]+)-c([0-9]+)-([0-9]+)-(.+)-([a-zA-Z]+)\.html   $1/brand.php?id=$2&cat=$3&page=$4&sort=$5&order=$6 [QSA,L]
    RewriteRule ^(.*)/brand-([0-9]+)-c([0-9]+)-([0-9]+)(.*)\.html                $1/brand.php?id=$2&cat=$3&page=$4 [QSA,L]
    RewriteRule ^(.*)/brand-([0-9]+)-c([0-9]+)(.*)\.html                         $1/brand.php?id=$2&cat=$3 [QSA,L]
    RewriteRule ^(.*)/brand-([0-9]+)(.*)\.html                                   $1/brand.php?id=$2 [QSA,L]
    RewriteRule ^(.*)/tag-(.*)\.html                                             $1/search.php?keywords=$2&notstatic=1 [QSA,L]
    RewriteRule ^(.*)/snatch-([0-9]+)\.html$                                     $1/snatch.php?id=$2&notstatic=1 [QSA,L]
    RewriteRule ^(.*)/group_buy-([0-9]+)\.html$                                  $1/group_buy.php?act=view&id=$2 [QSA,L]
    RewriteRule ^(.*)/auction-([0-9]+)\.html$                                    $1/auction.php?act=view&id=$2&notstatic=1 [QSA,L]
    RewriteRule ^(.*)/exchange-id([0-9]+)(.*)\.html$                             $1/exchange\.php\?id=$2&act=view [QSA,L]
    RewriteRule ^(.*)/exchange-([0-9]+)-min([0-9]+)-max([0-9]+)-([0-9]+)-(.+)-([a-zA-Z]+)(.*)\.html$ $1/exchange\.php\?cat_id=$2&integral_min=$3&integral_max=$4&page=$5&sort=$6&order=$7 [QSA,L]
    RewriteRule ^(.*)/exchange-([0-9]+)-([0-9]+)-(.+)-([a-zA-Z]+)(.*)\.html$                         $1/exchange\.php\?cat_id=$2&page=$3&sort=$4&order=$5 [QSA,L]
    RewriteRule ^(.*)/exchange-([0-9]+)-([0-9]+)(.*)\.html$                                          $1/exchange\.php\?cat_id=$2&page=$3  [QSA,L]
    RewriteRule ^(.*)/exchange-([0-9]+)(.*)\.html$                                                   $1/exchange\.php\?cat_id=$2  [QSA,L]
    RewriteRule ^(.*)/message-([0-9]+)(.*)\.html$                                 $1/message.php?id=$2 [QSA,L]
    </IfModule>
[/code]

ljl88 发表于 2010-6-22 11:28

[b]回复 [url=http://bbs.ecshop.com/redirect.php?goto=findpost&pid=567667&ptid=130606]11#[/url] [i]gezi_hui[/i] [/b]

插件很难解决问题,因为网页上的有些东西是没办法完全静态化的,比如用户登录信息、购物车信息、浏览历史等,所以最后还是要去修改原始程序,把不能静态化的部分提出来,单独处理。此外,还有其它很多问题。这些问题都是ecshop在做真正静态化没有考虑到的。要真正解决问题,还是要修改原代码。

137147530 发表于 2010-6-22 11:45

[i=s] 本帖最后由 137147530 于 2010-6-22 11:50 编辑 [/i]

请教几个问题,谢谢:

1、之前的收录有动态的收录的页面,简单重写收录的页面,以及复杂重写收录的页面,做了这个完全静态功能后,能自动跳转到这个纯静态页面吗。

2、如果文章有分页,文章分页能正常静态吗?

ljl88 发表于 2010-6-22 11:58

[i=s] 本帖最后由 ljl88 于 2010-7-11 23:46 编辑 [/i]

[font=宋体][size=5][color=#000000]版本历史[/color][/size][/font]
[table]
[tr][td=1,1,91][font=宋体][size=3][color=#000000]版本号[/color][/size][/font][/td][td=1,1,60][font=宋体][size=3][color=#000000]作者[/color][/size][/font][/td][td=1,1,94][font=宋体][size=3][color=#000000]时间[/color][/size][/font][/td][td=1,1,323][font=宋体][size=3][color=#000000]内容[/color][/size][/font][/td][/tr]
[tr][td=1,1,91][font=Times New Roman][size=3][color=#000000]V1.0[/color][/size][/font][/td][td=1,1,60][font=Times New Roman][size=3][color=#000000]yak[/color][/size][/font][/td][td=1,1,94][font=Times New Roman][size=3][color=#000000]2010-6-23[/color][/size][/font][/td][td=1,1,323][font=Times New Roman][color=#000000][size=3]1、[/size]
[/color][/font][size=3][color=#000000][font=宋体]利用[/font][font=Times New Roman]URL[/font][font=宋体]重写,将[/font][font=Times New Roman]html[/font][font=宋体]映射到[/font][font=Times New Roman]php[/font][font=宋体]上。但在每次访问时,都先通过[/font][font=Times New Roman]apache url rewrite[/font][font=宋体]规则判断静态页面是否存在,如果不存在,则访问[/font][font=Times New Roman]php[/font][font=宋体],并生成相应的[/font][font=Times New Roman]html[/font][font=宋体]页面;如果存在,则直接访问静态页面。[/font][/color][/size][font=Times New Roman][color=#000000][size=3]2、[/size]
[/color][/font][size=3][color=#000000][font=宋体]如果[/font][font=Times New Roman]php[/font][font=宋体]文件或者页面内容作了修改,则只需要删除静态页面即可,在用户下次访问时,即可自动重新生成静态页面。[/font][/color][/size][font=Times New Roman][color=#000000][size=3]3、[/size]
[/color][/font][size=3][color=#000000][font=宋体]对于页面中动态更新的部分需要进行单独处理,比如用户登录的状态、浏览历史、购物车信息等。在此方案中,采用了[/font][font=Times New Roman]javascript[/font][font=宋体]动态调用方法,对部分程序进行了修改。[/font][/color][/size][font=Times New Roman][color=#000000][size=3]4、[/size]
[/color][/font][font=宋体][size=3][color=#000000]主要针对首页、频道页、产品分类页、产品页、文章列表页、文章页等页面进行静态化。对于完全动态的页面,比如用户中心、搜索结果页面,则不做静态化处理。[/color][/size][/font][/td][/tr]
[tr][td=1,1,91][font=Times New Roman][size=3][color=#000000]V1.1[/color][/size][/font][/td][td=1,1,60][font=Times New Roman][size=3][color=#000000]yak[/color][/size][/font][/td][td=1,1,94][font=Times New Roman][size=3][color=#000000]2010-7-11[/color][/size][/font][/td][td=1,1,323][size=3][color=#000000][font=Times New Roman]1[/font][font=宋体]、在删除全部静态页面的基础上,增加了删除已更新静态页面的功能,方法是根据用户操作记录,只删除已更新静态页面,而不是全部删除。[/font][/color][/size][size=3][color=#000000][font=Times New Roman]2[/font][font=宋体]、修改了计划任务的执行时间选项,新增了“每隔[/font][font=Times New Roman]N[/font][font=宋体]分钟”间隔执行的可选项。[/font][/color][/size][size=3][color=#000000][font=Times New Roman]3[/font][font=宋体]、修改了[/font][font=Times New Roman]apache[/font][font=宋体]的重写脚本,将一些更新频繁的页面由真静态化改为伪静态化。[/font][/color][/size][/td][/tr]
[/table][p=30, 2, left][font=Times New Roman][color=#000000] [/color][/font][/p]

ljl88 发表于 2010-6-22 12:07

[quote]请教几个问题,谢谢:

1、之前的收录有动态的收录的页面,简单重写收录的页面,以及复杂重写收录的页面, ...
[size=2][color=#999999]137147530 发表于 2010-6-22 11:45[/color] [url=http://bbs.ecshop.com/redirect.php?goto=findpost&pid=567697&ptid=130606][img]http://bbs.ecshop.com/images/common/back.gif[/img][/url][/size][/quote]


   动态页面、简单重写页面,规则还是跟以前一样的,如果以前被搜索收录的,还是能正常访问。复杂重写可能就不行了,不过你可以自己添加URL Rewrite规则来实现跳转。
  
  文章分页应该可以正常静态化,不过我还没测试过。

[color=Red]  不过说明一下,这个静态化方案只是一个参考方案,你如果要实施的话,最好你本身懂PHP,会修改程序才行。不然容易出问题。[/color]

gzyanlin 发表于 2010-6-22 12:27

不错的东西支持一下,伪静态真的很有用不过就是用户中心还有搜索的不能也伪成静态

137147530 发表于 2010-6-23 10:09

文章分页不能实现静态化,请解决一下。

gxb220 发表于 2010-6-23 10:25

我刚看了下您修改的源代码,生成后的静态页文件存放在了根目录的 html 文件夹里了,但是在解析模板的时候,路径并没有相应的修改,所以生成静态页后,所有的样式、图片、js文件调用的路径都错误了。。。
如果生成后的文件放在根目录,问题可以解决,但是文件多的话,不利于管理。。。
LZ能否把这问题也解决一下呢?感激不尽。。。:)

levi6717 发表于 2010-6-23 10:40

支持,好东西

ljl88 发表于 2010-6-25 17:47

[quote]我刚看了下您修改的源代码,生成后的静态页文件存放在了根目录的 html 文件夹里了,但是在解析模板的时候, ...
[size=2][color=#999999]gxb220 发表于 2010-6-23 10:25[/color] [url=http://bbs.ecshop.com/redirect.php?goto=findpost&pid=568160&ptid=130606][img]http://bbs.ecshop.com/images/common/back.gif[/img][/url][/size][/quote]


    这个就是访问路径的问题。不能直接去访问html目录,比如:[url]http://ecshop.uckaka.com/html/index.html[/url],这样是不行的。所以需要通过apache的url rewrite来重写访问路径,虽然浏览器上显示的是[url]http://ecshop.uckaka.com/index.html[/url],但映射的是html下的index.html。

ljl88 发表于 2010-6-25 17:52

[color=Blue]补充说明一下,重写脚本httpd.conf或者htaccess.txt我都是在linux下测试的,如果您用的windows操作系统,我不确定是否能够使用。[/color]

枫叶飘丹 发表于 2010-6-26 19:47

不错 不错 支持下。嘎嘎

wjzhhr 发表于 2010-6-29 11:25

[code]补充说明一下,重写脚本httpd.conf或者htaccess.txt我都是在linux下测试的,如果您用的windows操作系统,我不确定是否能够使用。[/code]只要是apache的服务器或者nginx的都支持,但httpd.conf我没有见过

zpinsist 发表于 2010-6-30 19:48

虽然看不懂,但是还是顶一下!

kenter 发表于 2010-6-30 20:09

LZ人真好顶一下

lshzhuhai 发表于 2010-6-30 20:11

很细心,还有文档在里面,支持一下

meicheng 发表于 2010-7-10 19:40

先测试用下..看了,文档..很详细...先顶一下.. {:3_56:}

yifeng521 发表于 2010-7-10 20:17

支持一下,不错的东东

hemingxun 发表于 2010-7-11 15:49

历史上最牛的帖子

页: [1] 2 3

Powered by Discuz! Archiver 7.2  © 2001-2009 Comsenz Inc.