IIS7判斷pc和移動跳轉(zhuǎn)

admin 建站教程評論7891字?jǐn)?shù) 2178閱讀模式

在windows2008下配置II7 web.config

當(dāng)通過手機(jī)訪問www域名時(shí),自動跳轉(zhuǎn)到對應(yīng)的移動域名下

  1. <?xml version="1.0" encoding="UTF-8"?>    
  2. <configuration>  
  3. <system.webServer>    
  4.     <!-- http://www.whsir.com 替換為對應(yīng)的網(wǎng)站,帶www-->    
  5.     <httpRedirect enabled="false" destination="http://www.whsir.com" exactDestination="false" childOnly="false" httpResponseStatus="Permanent" />    
  6.     <!--啟用Gzip壓縮-->    
  7.     <urlCompression doStaticCompression="true" doDynamicCompression="false" />    
  8.     <defaultDocument>    
  9.         <files>    
  10.             <clear />    
  11.                 <add value="Default.htm" />  
  12.                 <add value="Default.asp" />  
  13.                 <add value="index.htm" />  
  14.                 <add value="index.html" />  
  15.                 <add value="index.php" />  
  16.                 <add value="default.aspx" />  
  17.         </files>    
  18.     </defaultDocument>    
  19. </system.webServer>    
  20. <system.webServer>    
  21.     <rewrite>    
  22.         <rules>    
  23.             <rule name="WWW Redirect" stopProcessing="true">    
  24.                 <match url=".*" />    
  25.                 <conditions>    
  26.                     <!--xxx.com,替換為對應(yīng)的網(wǎng)站,不帶www-->    
  27.                     <add input="{HTTP_HOST}" pattern="^whsir.com$" />    
  28.                 </conditions>    
  29.                 <!-- http://www.whsir.com 替換為對應(yīng)的網(wǎng)站,帶www-->    
  30.                 <action type="Redirect" url="http://www.whsir.com/{R:0}" redirectType="Permanent" />    
  31.             </rule>    
  32.             <rule name="Mobile Jump" stopProcessing="true">    
  33.                 <match url="^(.*)$" />  
  34.                 <conditions logicalGrouping="MatchAll">  
  35.                         <add input="{HTTP_USER_AGENT}" pattern="(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino" />  
  36.                 </conditions>  
  37.                 <!-- 輸入要跳轉(zhuǎn)的手機(jī)站點(diǎn) -->  
  38.                 <action type="Redirect" url="http://m.whsir.com/" redirectType="Found" />  
  39.             </rule>  
  40.         </rules>  
  41.     </rewrite>  
  42. </system.webServer>  
  43. </configuration>  

版權(quán)聲明:文章圖片資源來源于網(wǎng)絡(luò),如有侵權(quán),請留言刪除!!!
廣告也精彩
admin
  • 本文由 發(fā)表于 2021年2月25日 11:59:25
  • 轉(zhuǎn)載請務(wù)必保留本文鏈接:http://yudch.cn/7216.html
匿名

發(fā)表評論

匿名網(wǎng)友 填寫信息

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: