ecshop rewrite規則重寫Apache換IIS7

來源:互聯網
上載者:User

因為種種原因,這次朋友公司的伺服器必須使用IIS7作為web伺服器,不能使用我一貫使用的apache,所以在這次遷移過程中,rewrite這裡出了點小小的問題。最後圓滿解決。其實iisrewrite配置成功後,相應的rewrite規則寫到根目錄的web.config檔案中即可。ecshop2.7.3對應的規則如下

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <system.webServer>
    <rewrite>
      <rules>
        <rule name="Index" stopProcessing="true">
          <match url="^index.html" />
          <action type="Rewrite" url="index.php" />
        </rule>
        <rule name="Feed-C" stopProcessing="true">
          <match url="^feed-c([0-9]+).xml" />
          <action type="Rewrite" url="feed.php?cat={R:1}" />
        </rule>
        <rule name="Feed-B" stopProcessing="true">
          <match url="^feed-b([0-9]+).xml" />
          <action type="Rewrite" url="feed.php?brand={R:1}" />
        </rule>
        <rule name="Feed" stopProcessing="true">
          <match url="^feed.xml" />
          <action type="Rewrite" url="feed.php" />
        </rule>
        <rule name="Category6" stopProcessing="true">
          <match url="^category-([0-9]+)-b([0-9]+)-min([0-9]+)-max([0-9]+)-attr([^-]*)-([0-9]+)-(.+)-([_0-9a-z-]+).html" />
          <action type="Rewrite" url="category.php?id={R:1}&amp;brand={R:2}&amp;price_min={R:3}&amp;price_max={R:4}&amp;filter_attr={R:5}&amp;page={R:6}&amp;sort={R:7}&amp;order={R:8}" />
        </rule>
        <rule name="Category5" stopProcessing="true">
          <match url="^category-([0-9]+)-b([0-9]+)-min([0-9]+)-max([0-9]+)-attr([^-]*).html" />
          <action type="Rewrite" url="category.php?id={R:1}&amp;brand={R:2}&amp;price_min={R:3}&amp;price_max={R:4}&amp;filter_attr={R:5}" />
        </rule>
        <rule name="Category4" stopProcessing="true">
          <match url="^category-([0-9]+)-b([0-9]+)-([0-9]+)-(.+)-([_0-9a-z-]+).html" />
          <action type="Rewrite" url="category.php?id={R:1}&amp;brand={R:2}&amp;page={R:3}&amp;sort={R:4}&amp;order={R:5}" />
        </rule>
        <rule name="Category3" stopProcessing="true">
          <match url="^category-([0-9]+)-b([0-9]+)-([0-9]+).html" />
          <action type="Rewrite" url="category.php?id={R:1}&amp;brand={R:2}&amp;page={R:3}" />
        </rule>
        <rule name="Category2" stopProcessing="true">
          <match url="^category-([0-9]+)-b([0-9]+).html" />
          <action type="Rewrite" url="category.php?id={R:1}&amp;brand={R:2}" />
        </rule>
        <rule name="Category1" stopProcessing="true">
          <match url="^category-([0-9]+).html" />
          <action type="Rewrite" url="category.php?id={R:1}" />
        </rule>
        <rule name="Goods" stopProcessing="true">
          <match url="^goods-([0-9]+).html" />
          <action type="Rewrite" url="goods.php?id={R:1}" />
        </rule>
        <rule name="Cat3" stopProcessing="true">
          <match url="^article_cat-([0-9]+)-([0-9]+)-(.+)-([_0-9a-z-]+).html" />
          <action type="Rewrite" url="article_cat.php?id={R:1}&amp;page={R:2}&amp;sort={R:3}&amp;order={R:4}" />
        </rule>
        <rule name="Cat2" stopProcessing="true">
          <match url="^article_cat-([0-9]+)-([0-9]+).html" />
          <action type="Rewrite" url="article_cat.php?id={R:1}&amp;page={R:2}" />
        </rule>
        <rule name="Cat1" stopProcessing="true">
          <match url="^article_cat-([0-9]+).html" />
          <action type="Rewrite" url="article_cat.php?id={R:1}" />
        </rule>
        <rule name="Articles" stopProcessing="true">
          <match url="^article-([0-9]+).html" />
          <action type="Rewrite" url="article.php?id={R:1}" />
        </rule>
        <rule name="Brand4" stopProcessing="true">
          <match url="^brand-([0-9]+)-c([0-9]+)-([0-9]+)-(.+)-([_0-9a-z-]+).html" />
          <action type="Rewrite" url="brand.php?id={R:1}&amp;cat={R:2}&amp;page={R:3}&amp;sort={R:4}&amp;order={R:5}" />
        </rule>
        <rule name="Brand3" stopProcessing="true">
          <match url="^brand-([0-9]+)-c([0-9]+)-([0-9]+).html" />
          <action type="Rewrite" url="brand.php?id={R:1}&amp;cat={R:2}&amp;page={R:3}" />
        </rule>
        <rule name="Brand2" stopProcessing="true">
          <match url="^brand-([0-9]+)-c([0-9]+).html" />
          <action type="Rewrite" url="brand.php?id={R:1}&amp;cat={R:2}" />
        </rule>
        <rule name="Brand1" stopProcessing="true">
          <match url="^brand-([0-9]+).html" />
          <action type="Rewrite" url="brand.php?id={R:1}" />
        </rule>
        <rule name="Search" stopProcessing="true">
          <match url="^tag-([_0-9a-z-]+).html" />
          <action type="Rewrite" url="search.php?keywords={R:1}" />
        </rule>
        <rule name="Snatch" stopProcessing="true">
          <match url="^snatch-([0-9]+).html" />
          <action type="Rewrite" url="snatch.php?id={R:1}" />
        </rule>
        <rule name="Group_Buy" stopProcessing="true">
          <match url="^group_buy-([0-9]+).html" />
          <action type="Rewrite" url="group_buy.php?act=view&amp;id={R:1}" />
        </rule>
        <rule name="Auction" stopProcessing="true">
          <match url="^auction-([0-9]+).html" />
          <action type="Rewrite" url="auction.php?act=view&amp;id={R:1}" />
        </rule>
        <rule name="Exchange5" stopProcessing="true">
          <match url="^exchange-id([0-9]+).html" />
          <action type="Rewrite" url="exchange.php?id={R:1}&amp;act=view" />
        </rule>
        <rule name="Exchange4" stopProcessing="true">
          <match url="^exchange-([0-9]+)-min([0-9]+)-max([0-9]+)-([0-9]+)-(.+)-([_0-9a-z-]+).html" />
          <action type="Rewrite" url="exchange.php?cat_id={R:1}&amp;integral_min={R:2}&amp;integral_max={R:3}&amp;page={R:4}&amp;sort={R:5}&amp;order={R:6}" />
        </rule>
        <rule name="Exchange3" stopProcessing="true">
          <match url="^exchange-([0-9]+)-([0-9]+)-(.+)-([_0-9a-z-]+).html" />
          <action type="Rewrite" url="exchange.php?cat_id={R:1}&amp;page={R:2}&amp;sort={R:3}&amp;order={R:4}" />
        </rule>
        <rule name="Exchange2" stopProcessing="true">
          <match url="^exchange-([0-9]+)-([0-9]+).html" />
          <action type="Rewrite" url="exchange.php?cat_id={R:1}&amp;page={R:2}" />
        </rule>
        <rule name="Exchange1" stopProcessing="true">
          <match url="^exchange-([0-9]+).html" />
          <action type="Rewrite" url="exchange.php?cat_id={R:1}" />
        </rule>
        <rule name="Topic" stopProcessing="true">
          <match url="^topic-([0-9]+).html" />
          <action type="Rewrite" url="topic.php?topic_id={R:1}" />
        </rule>
      </rules>
    </rewrite>
  </system.webServer>
</configuration>

一開始網站試了很多規則,都提示某行錯誤,白色不得其解,後來發現是“&”搞的鬼,把對應的“&”都修改為“&amp;”即可。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.