ecshop在apache下的伪静态规则范例

  • 时间:
  • 浏览:22

伪静态技术现在在网站建设中应用的越来越多了,运用伪静态技术后,可以给网站带来很多好处。一是更利于搜索引擎的抓取,增加网页的收录量,提升网站的排名,还可以在一定程度上防止网站被攻击。


那么ecshop在apache下的伪静态规则是怎么样的呢?以下我给出一个基于在apache下的伪静态参考范例。范例中集成了ecshop默认的一些常用的url静态规则,如果你自己定义了新的页面,可以按照下面范例的规则仿照的进行添加。


复制下面这段代码,然后存为 .htaccess 放到站点的根目录下面就行了。(请确保您的空间/服务器是安装的apache,如果是iis,请参考代潇瑞博客中的 ecshop在iis下的伪静态规则范例


    order deny,allow

    deny from all


RewriteEngine On

RewriteBase /


# direct one-word access

RewriteRule ^index\.html$    index\.PHP [L]

RewriteRule ^category$      index\.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]+)-([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-9a-zA-Z_]+)-([0-9]+)(.*)\.html$  goods\.php\?id=$2 [QSA,L]

RewriteRule ^goods-([0-9]+)(.*)\.html$   goods\.php\?id=$1 [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 [QSA,L]

RewriteRule ^snatch-([0-9]+)\.html$                                     snatch\.php\?id=$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 [QSA,L]