1.重定向:http转https

<rule name="reto https" stopProcessing="true"> 
  <match url="(.*)"/>  
  <conditions> 
    <add input="{HTTPS}" pattern="off" ignoreCase="true"/> 
  </conditions>  
  <action type="Redirect" redirectType="Found" url="https://{HTTP_HOST}/{R:1}"/> 

</rule>


2.重写:反向代理,iis部署vue前后端分离项目

指定首页

<rule name="exclude the path" enabled="true" patternSyntax="Wildcard" stopProcessing="true"> 
  <match url="*"/>  
  <conditions logicalGrouping="MatchAll" trackAllCaptures="false"> 
    <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true"/>  
    <add input="{HTTP_ACCEPT}" pattern="application/json*" negate="true"/>  
    <add input="{CONTENT_TYPE}" pattern="multipart/form-data*" negate="true"/> 
  </conditions>  
  <action type="Rewrite" url="/index.html" logRewrittenUrl="true"/>  
  <serverVariables></serverVariables> 

</rule>


 单独文件服务器

<rule name="files" stopProcessing="true"> 
  <match url="^(.*)"/>  
  <conditions logicalGrouping="MatchAny" trackAllCaptures="false"> 
    <add input="{CONTENT_TYPE}" pattern="^multipart/form-data"/> 
  </conditions>  
  <action type="Rewrite" url="https://file.xxx.com/{R:1}"/> 

</rule>


 普通数据(ajax下通过json传输)

 
<rule name="ajax" stopProcessing="true"> 
  <match url="^(.*)"/>  
  <conditions logicalGrouping="MatchAny" trackAllCaptures="false"> 
    <add input="{CONTENT_TYPE}" pattern="^application/json"/>  
    <add input="{HTTP_ACCEPT}" pattern="^application/json"/> 
  </conditions>  
  <action type="Rewrite" url="https://api.xxx.com/{R:1}"/> 
</rule>
 


以上就是网站服务器IIS中,web.config 重写规则的详细内容,更多信息请关注OD云其它相关文章!



本文URL:http://www.odweb.cn/news_show.html?id=226