Win2008 IIS7下 可用的伪静态规则

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



生产环境如下:
OS:Win2008
Web 服务器:Microsoft-IIS/7.0
Fastcgi模式
URL Rewrite Module 2.0(微软官方:http://www.iis.net/download/URLRewrite)
PHP 版本:5.2.17
ECShop 版本:v2.7.3 RELEASE 20120411
编码:UTF-8

因为懒,就在网上找了N次方个规则,结果没有一个能正常使用的(包括EC安装包里的静态规则,在以上的环境中也无法正常使用)。看来还是需要自己动手,才能丰衣足食。

规则如下:
  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 0">
  11. <match url="^category$" />
  12. <action type="Rewrite" url="index.php" />
  13. </rule>
  14. <rule name="feed category">
  15. <match url="^feed-c([0-9]+).xml$" />
  16. <action type="Rewrite" url="feed.php?cat={R:1}" />
  17. </rule>
  18. <rule name="feed brand">
  19. <match url="^feed-b([0-9]+).xml$" />
  20. <action type="Rewrite" url="feed.php?brand={R:1}" />
  21. </rule>
  22. <rule name="feed type">
  23. <match url="^feed-type([^-]+).xml$" />
  24. <action type="Rewrite" url="feed.php?type={R:1}" />
  25. </rule>
  26. <rule name="feed">
  27. <match url="^feed.xml$" />
  28. <action type="Rewrite" url="feed.php" />
  29. </rule>
  30. <rule name="category 1">
  31. <match url="^category-([0-9]+)-b([0-9]+)-min([0-9]+)-max([0-9]+)-attr([^-]*)-([0-9]+)-(.+)-([a-zA-Z]+)(.*).html" />
  32. <action type="Rewrite" url="category.php?id={R:1}&brand={R:2}&price_min={R:3}&price_max={R:4}&filter_attr={R:5}&page={R:6}&sort={R:7}&order={R:8}" />
  33. </rule>
  34. <rule name="category 2">
  35. <match url="^category-([0-9]+)-b([0-9]+)-min([0-9]+)-max([0-9]+)-attr([^-]*)(.*).html" />
  36. <action type="Rewrite" url="category.php?id={R:1}&brand={R:2}&price_min={R:3}&price_max={R:4}&filter_attr={R:5}" />
  37. </rule>
  38. <rule name="category 3">
  39. <match url="^category-([0-9]+)-b([0-9]+)-([0-9]+)-(.+)-([a-zA-Z]+)(.*).html" />
  40. <action type="Rewrite" url="category.php?id={R:1}&brand={R:2}&page={R:3}&sort={R:4}&order={R:5}" />
  41. </rule>
  42. <rule name="category 4">
  43. <match url="^category-([0-9]+)-b([0-9]+)-([0-9]+)(.*).html" />
  44. <action type="Rewrite" url="category.php?id={R:1}&brand={R:2}&page={R:3}" />
  45. </rule>
  46. <rule name="category 5">
  47. <match url="^category-([0-9]+)-b([0-9]+)(.*).html" />
  48. <action type="Rewrite" url="category.php?id={R:1}&brand={R:2}" />
  49. </rule>
  50. <rule name="category 6">
  51. <match url="^category-([0-9]+)(.*).html" />
  52. <action type="Rewrite" url="category.php?id={R:1}" />
  53. </rule>
  54. <rule name="category 7">
  55. <match url="^category-([0-9]+)-b([0-9]+).html(.*)$" ignoreCase="false" />
  56. <action type="Rewrite" url="category.php?{R:3}&id={R:1}&brand={R:2}" />
  57. </rule>
  58. <rule name="goods">
  59. <match url="^goods-([0-9]+)(.*).html" />
  60. <action type="Rewrite" url="goods.php?id={R:1}" />
  61. </rule>
  62. <rule name="article 0">
  63. <match url="^article_cat-([0-9]+)-([0-9]+)-(.+)-([a-zA-Z]+)(.*).html" />
  64. <action type="Rewrite" url="article_cat.php?id={R:1}&page={R:2}&sort={R:3}&order={R:4}" />
  65. </rule>
  66. <rule name="article 1">
  67. <match url="^article_cat-([0-9]+)-([0-9]+)-(.+)(.*).html" />
  68. <action type="Rewrite" url="article_cat.php?id={R:1}&page={R:1}&keywords={R:2}" />
  69. </rule>
  70. <rule name="article 2">
  71. <match url="^article_cat-([0-9]+)-([0-9]+)(.*).html" />
  72. <action type="Rewrite" url="article_cat.php?id={R:1}&page={R:2}" />
  73. </rule>
  74. <rule name="article 3">
  75. <match url="^article_cat-([0-9]+)(.*).html" />
  76. <action type="Rewrite" url="article_cat.php?id={R:1}" />
  77. </rule>
  78. <rule name="article 4">
  79. <match url="^article-([0-9]+)(.*).html" />
  80. <action type="Rewrite" url="article.php?id={R:1}" />
  81. </rule>
  82. <rule name="brand 0">
  83. <match url="^brand-([0-9]+)-c([0-9]+)-([0-9]+)-(.+)-([a-zA-Z]+).html" />
  84. <action type="Rewrite" url="brand.php?id={R:1}&cat={R:2}&page={R:3}&sort={R:4}&order={R:5}" />
  85. </rule>
  86. <rule name="brand 1">
  87. <match url="^brand-([0-9]+)-c([0-9]+)-([0-9]+)(.*).html" />
  88. <action type="Rewrite" url="brand.php?id={R:1}&cat={R:2}&page={R:3}" />
  89. </rule>
  90. <rule name="brand 2">
  91. <match url="^brand-([0-9]+)-c([0-9]+).html(.*)$" />
  92. <action type="Rewrite" url="brand.php?{R:3}&id={R:1}&cat={R:2}" />
  93. </rule>
  94. <rule name="brand 3">
  95. <match url="^brand-([0-9]+)-c([0-9]+)(.*).html" />
  96. <action type="Rewrite" url="brand.php?id={R:1}&cat={R:2}" />
  97. </rule>
  98. <rule name="brand 4">
  99. <match url="^brand-([0-9]+)(.*).html" />
  100. <action type="Rewrite" url="brand.php?id={R:1}" />
  101. </rule>
  102. <rule name="tag">
  103. <match url="^tag-(.*).html" />
  104. <action type="Rewrite" url="search.php?keywords={R:1}" />
  105. </rule>
  106. <rule name="snatch">
  107. <match url="^snatch-([0-9]+).html" />
  108. <action type="Rewrite" url="snatch.php?id={R:1}" />
  109. </rule>
  110. <rule name="group">
  111. <match url="^group_buy-([0-9]+).html" />
  112. <action type="Rewrite" url="group_buy.php?act=view&id={R:1}" />
  113. </rule>
  114. <rule name="auction">
  115. <match url="^auction-([0-9]+).html" />
  116. <action type="Rewrite" url="auction.php?act=view&id={R:1}" />
  117. </rule>
  118. <rule name="exchange 0">
  119. <match url="^exchange-id([0-9]+)(.*).html" />
  120. <action type="Rewrite" url="exchange.php?id={R:1}&act=view" />
  121. </rule>
  122. <rule name="exchange 1">
  123. <match url="^exchange-([0-9]+)-min([0-9]+)-max([0-9]+)-([0-9]+)-(.+)-([a-zA-Z]+)(.*).html" />
  124. <action type="Rewrite" url="exchange.php?cat_id={R:1}&integral_min={R:2}&integral_max={R:3}&page={R:4}&sort={R:5}&order={R:6}" />
  125. </rule>
  126. <rule name="exchange 2">
  127. <match url="^exchange-([0-9]+)-([0-9]+)-(.+)-([a-zA-Z]+)(.*).html" />
  128. <action type="Rewrite" url="exchange.php?cat_id={R:1}&page={R:2}&sort={R:3}&order={R:4}" />
  129. </rule>
  130. <rule name="exchange 3">
  131. <match url="^exchange-([0-9]+)-([0-9]+)(.*).html" />
  132. <action type="Rewrite" url="exchange.php?cat_id={R:1}&page={R:2}" />
  133. </rule>
  134. <rule name="exchange 4">
  135. <match url="^exchange-([0-9]+)(.*).html" />
  136. <action type="Rewrite" url="exchange.php?cat_id={R:1}" />
  137. </rule>
  138. </rules>
  139. </rewrite>
  140. </system.webServer>
  141. </configuration>
复制代码


懒人包:UTF8格式 web_config.rar (904 Bytes)

才疏学浅,错误难免,请嘴下留情,不要井喷~ 谢

回答:
感谢楼主分享~ 先收藏了~~

不错不错啊 直接收藏了再说

楼主是个好人,支持.