网站地图    收藏   

主页 > 后端 > ecshop教程 >

ecshop中iis/apache伪静态规则配置示例 - ecshop

来源:自学PHP网    时间:2014-11-28 23:31 作者: 阅读:

[导读] 伪静态是现在网站建设技术中一门高常用的技术了,我们可以利用伪静态来实现网站像php一样更新全部自动更新,修改模板所有页面一并修改了,下文我们一起来看看ecshop中iis/apache伪静态规...

ecshop中iis/apache伪静态规则配置示例

伪静态是现在网站建设技术中一门高常用的技术了,我们可以利用伪静态来实现网站像php一样更新全部自动更新,修改模板所有页面一并修改了,下文我们一起来看看ecshop中iis/apache伪静态规则配置示例.

apache下的伪静态规则范例

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

  1. <FilesMatch "\.(bak|inc|lib|sh|tpl|lbi|dwt)$"
  2.     order deny,allow 
  3.     deny from all 
  4. </FilesMatch> 
  5.  
  6. RewriteEngine On 
  7. RewriteBase / 
  8.  
  9. # direct one-word access 
  10. RewriteRule ^index\.html$    index\.php [L] 
  11. RewriteRule ^category$      index\.php [L] 
  12.  
  13. # access any object by its numeric identifier 
  14. RewriteRule ^feed-c([0-9]+)\.xml$    feed\.php\?cat=$1 [L] 
  15. RewriteRule ^feed-b([0-9]+)\.xml$    feed\.php\?brand=$1 [L] 
  16. RewriteRule ^feed-type([^-]+)\.xml$  feed\.php\?type=$1 [L] 
  17. RewriteRule ^feed\.xml$     feed\.php [L] 
  18.  
  19. RewriteRule ^category-([0-9]+)-b([0-9]+)-([0-9]+)(.*)\.html$  category\.php\?id=$1&brand=$2&page=$3  [QSA,L] 
  20. RewriteRule ^category-([0-9]+)-b([0-9]+)(.*)\.html$   category\.php\?id=$1&brand=$2  [QSA,L] 
  21. RewriteRule ^category-([0-9]+)(.*)\.html$   category\.php\?id=$1  [QSA,L] 
  22.  
  23. RewriteRule ^goods-([0-9a-zA-Z_]+)-([0-9]+)(.*)\.html$  goods\.php\?id=$2 [QSA,L] 
  24. RewriteRule ^goods-([0-9]+)(.*)\.html$   goods\.php\?id=$1 [QSA,L] 
  25.  
  26. RewriteRule ^article_cat-([0-9]+)-([0-9]+)(.*)\.html$                   article_cat\.php\?id=$1&page=$2   [QSA,L] 
  27. RewriteRule ^article_cat-([0-9]+)(.*)\.html$                            article_cat\.php\?id=$1   [QSA,L] 
  28. RewriteRule ^article-([0-9]+)(.*)\.html$                                article\.php\?id=$1   [QSA,L] 
  29.  
  30. 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] 
  31. RewriteRule ^brand-([0-9]+)-c([0-9]+)-([0-9]+)(.*)\.html                brand\.php\?id=$1&cat=$2&page=$3 [QSA,L] 
  32. RewriteRule ^brand-([0-9]+)-c([0-9]+)(.*)\.html                         brand\.php\?id=$1&cat=$2 [QSA,L] 
  33. RewriteRule ^brand-([0-9]+)(.*)\.html                                   brand\.php\?id=$1 [QSA,L] 
  34.  
  35. RewriteRule ^tag-(.*)\.html                                             search\.php\?keywords=$1 [QSA,L] 
  36. RewriteRule ^snatch-([0-9]+)\.html$                                     snatch\.php\?id=$1 [QSA,L] 
  37. RewriteRule ^group_buy-([0-9]+)\.html$                                  group_buy\.php\?act=view&id=$1 [QSA,L] 
  38. RewriteRule ^auction-([0-9]+)\.html$                                    auction\.php\?act=view&id=$1 [QSA,L] 

iis下的伪静态规则范例

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

  1. <?xml version="1.0" encoding="UTF-8"?> 
  2. <configuration> 
  3.  <system.webServer> 
  4.   <rewrite> 
  5.    <rules> 
  6.     <rule name="index"
  7.      <match url="^index.html" /> 
  8.      <action type="Rewrite" url="index.php" /> 
  9.     </rule> 
  10.     <rule name="category"
  11.      <match url="^(.*/)*category.html" /> 
  12.      <action type="Rewrite" url="{R:1}/category.php" /> 
  13.     </rule> 
  14.     <rule name="category0"
  15.      <match url="^(.*/)*category-([0-9]+).html" /> 
  16.      <action type="Rewrite" url="{R:1}/category.php\?id={R:2}" /> 
  17.     </rule> 
  18.     <rule name="category1"
  19.      <match url="^(.*/)*category-([0-9]+)-([0-9]+)-(\w+).html" /> 
  20.      <action type="Rewrite" url="{R:1}/category.php\?id={R:2}&amp;page={R:3}" /> 
  21.     </rule> 
  22.     <rule name="brands"
  23.      <match url="^(.*/)*brands-([0-9]+).html" /> 
  24.      <action type="Rewrite" url="{R:1}/brands.php\?id={R:2}" /> 
  25.     </rule> 
  26.     <rule name="article"
  27.      <match url="^(.*/)*article-([0-9]+).html" /> 
  28.      <action type="Rewrite" url="{R:1}/article.php\?id={R:2}" /> 
  29.     </rule> 
  30.     <rule name="article_cat"
  31.      <match url="^(.*/)*article_cat-([0-9]+).html" /> 
  32.      <action type="Rewrite" url="{R:1}/article_cat.php\?id={R:2}" /> 
  33.     </rule> 
  34.     <rule name="article_cat_page"
  35.      <match url="^(.*/)*article_cat-([0-9]+)-([0-9]+).html" /> 
  36.      <action type="Rewrite" url="{R:1}/article_cat.php\?id={R:2}&amp;page={R:3}" /> 
  37.     </rule> 
  38.     <rule name="goods"
  39.      <match url="^(.*/)*goods-([0-9]+).html" /> 
  40.      <action type="Rewrite" url="{R:1}/goods.php\?id={R:2}" /> 
  41.     </rule> 
  42.     <rule name="contact"
  43.      <match url="^(.*/)*contact.html" /> 
  44.      <action type="Rewrite" url="{R:1}/contact.php" /> 
  45.     </rule> 
  46.     <rule name="search"
  47.      <match url="^(.*/)*search-([a-zA-Z]+).html" /> 
  48.      <action type="Rewrite" url="{R:1}/search.php\?intro={R:2}" /> 
  49.     </rule> 
  50.     <rule name="maps"
  51.      <match url="^(.*/)*maps.html" /> 
  52.      <action type="Rewrite" url="{R:1}/maps.php" /> 
  53.     </rule>//开源软件:phpfensi.com 
  54.    </rules> 
  55.   </rewrite> 
  56.  </system.webServer> 
  57. </configuration>

自学PHP网专注网站建设学习,PHP程序学习,平面设计学习,以及操作系统学习

京ICP备14009008号-1@版权所有www.zixuephp.com

网站声明:本站所有视频,教程都由网友上传,站长收集和分享给大家学习使用,如由牵扯版权问题请联系站长邮箱904561283@qq.com

添加评论