IIS7.0 Url Rewrite

1.  去微軟官網下載Url Reqrite Module  2.0安裝 ;

2. 關閉然後再打開IIS信息服務(IIS)管理器窗口,就能夠看到Url Rewrite模塊了 


3. 雙擊Url Rewrite模塊,就能看到如下界面進行規格配置


規則也可以直接去web.config文件配置。

如下是我配置的一個規則:移動端訪問PC端站點的時候直接跳轉到移動端站點

<system.webServer>
    <rewrite>
      <rules>
        <rule name="UserAgentRedirect" stopProcessing="true">
          <match url="^(.*)$" />
          <conditions>
            <add input="{HTTP_USER_AGENT}" pattern="(iphone|android|phone|mobile|wap|netfront|java|opera mobi,opera mini|ucweb|windows ce|symbian|series|webos|sony|blackberry|dopod,nokia|samsung|palmsource|xda|pieplus|meizu|midp|cldc|motorola|foma,docomo|up.browser|up.link|blazer|helio|hosin|huawei|novarra|coolpad|webos|techfaith|palmsource|alcatel|amoi|ktouch|nexian|ericsson|philips|sagem|wellcom|bunjalloo|maui|smartphone|iemobile|spice|bird|zte-|longcos|pantech|gionee|portalmmm|jig browser|hiptop|benq|haier|^lct|320x320|240x320|176x220|w3c |acs-|alav|alca|amoi|audi|avan|benq|bird|blac|blaz|brew|cell|cldc|cmd-|dang|doco|eric|hipt|inno|ipaq|java|jigs|kddi|keji|leno|lg-c|lg-d|lg-g|lge-|maui|maxo|midp|mits|mmef|mobi|mot-|moto|mwbp|nec-|newt|noki|oper|palm|pana|pant|phil|play|port|prox|qwap|sage|sams|sany|sch-|sec-|send|seri|sgh-|shar|sie-|siem|smal|smar|sony|sph-|symb|t-mo|teli|tim-|tosh|tsm-|upg1|upsi|vk-v|voda|wap-|wapa|wapi|wapp|wapr|webc|winw|winw|xda|xda-,Googlebot-Mobile)" />
          </conditions>
          <action type="Redirect" url="http://mobile.mysite.com" />
        </rule>
      </rules>
    </rewrite>
  </system.webServer>


4. 規則配置好後重新啓動站點,配置的規則就可以生效了;



發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章