IIS7判断pc和移动跳转

admin 建站教程评论6211字数 2178阅读模式

在windows2008下配置II7 web.config

当通过手机访问www域名时,自动跳转到对应的移动域名下

  1. <?xml version="1.0" encoding="UTF-8"?>    
  2. <configuration>  
  3. <system.webServer>    
  4.     <!-- http://www.whsir.com 替换为对应的网站,带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,替换为对应的网站,不带www-->    
  27.                     <add input="{HTTP_HOST}" pattern="^whsir.com$" />    
  28.                 </conditions>    
  29.                 <!-- http://www.whsir.com 替换为对应的网站,带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.                 <!-- 输入要跳转的手机站点 -->  
  38.                 <action type="Redirect" url="http://m.whsir.com/" redirectType="Found" />  
  39.             </rule>  
  40.         </rules>  
  41.     </rewrite>  
  42. </system.webServer>  
  43. </configuration>  

版权声明:文章图片资源来源于网络,如有侵权,请留言删除!!!
admin
  • 本文由 发表于 2021年2月25日 11:59:25
  • 转载请务必保留本文链接:https://www.58pxe.com/7216.html
匿名

发表评论

匿名网友 填写信息

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