iis的web.confg 中url重写与cros Configuring Inbound Rewrite Rules

最近有关注到web.config 配置,

有url 请求转发和跨域配置相关知识,

以下列出相关配置官网介绍:

Creating Rewrite Rules for the URL Rewrite Module | Microsoft Learn

<rewrite>
<rules>
<rule name="Fail bad requests">
<match url=".*"/>
<conditions>
<add input="{HTTP_HOST}" pattern="localhost" negate="true" />
</conditions>
<action type="AbortRequest" />
</rule>
<rule name="Redirect from blog">
<match url="^blog/([_0-9a-z-]+)/([0-9]+)" />
<action type="Redirect" url="article/{R:2}/{R:1}" redirectType="Found" />
</rule>
<rule name="Rewrite to article.aspx">
<match url="^article/([0-9]+)/([_0-9a-z-]+)" />
<action type="Rewrite" url="article.aspx?id={R:1}&amp;title={R:2}" />
</rule>
</rules>
</rewrite>

 

 以下是配置跨域请求:

CORS Module Configuration Reference | Microsoft Learn

 

posted @ 2023-03-10 13:57  星辰与大海  阅读(75)  评论(0)    收藏  举报