IIS RewriteRules Rewrite和Redirect 区别

当 type="Rewrite" 时, redirectType="Permanent" 是无效的,只有当type="Redirect" 时, redirectType="Permanent"才生效的,所以type="Rewrite" 时不要用redirectType="Permanent"。

type="Rewrite" 时,网址不变,只是网页内容是新网面的。

<rule name="RiLiBiao" enabled="true">

<match url="^rilibiao/(\w+?)-(\d{4})-(\d{3})\.html" />

<action type="Rewrite" url="/RiLiBiao.aspx?RAlias={R:1}&amp;RYear={R:2}&amp;RKind={R:3}" />

</rule>

type="Redirect" 时,网址会变的,相当于跳转到新网页了。

<rule name="RiLiBiao" enabled="true">

<match url="^rilibiao/(\w+?)-(\d{4})-(\d{3})\.html" />

<action type="Redirect" url="/RiLiBiao.aspx?RAlias={R:1}&amp;RYear={R:2}&amp;RKind={R:3}" redirectType="Permanent" />

</rule>

1. `type="Rewrite"`:**服务器内部转发,浏览器地址栏 URL 不变**,`redirectType` 属性**完全无效**,写了也会被 IIS 忽略,属于冗余代码,建议删掉。

2. `type="Redirect"`:**HTTP 重定向,浏览器收到 3xx 状态码,地址栏变更**,`redirectType` 才生效:

- `redirectType="Permanent"` → HTTP 301 永久重定向

- `redirectType="Temporary"` → HTTP 302 临时重定向

- `redirectType="SeeOther"` → HTTP 303

- `redirectType="Found"` → 旧版 302

- 伪静态展示(对外 URL 好看,实际跑 aspx):**用 Rewrite**

- 旧 URL 废弃,永久迁移到新地址:**用 Redirect + Permanent(301)**

文件名精灵2025年最新版 机器翻译 AI智能
...
批量修改文件名称、文件夹名称

免费使用 功能无限制

全面接入机器自动翻译功能,主流AI大模型智能改名

方便快捷,支持正则表达式、无需安装功能齐全、支持定制无广告、无插件,放心使用。

点击下载 点击下载
本站中所有的计算器的计算结果仅供参考,本站对此结果的准确性不承担任何责任,实际数额以银行/保险公司/国家相关机构确认的结果为准。
在线客服QQ:543690914,备案号: 苏ICP备15037649号-27。东海县白塔埠镇佳诚电脑经营部版权所有。