[英]Automating URL Rewrite IIS
I'm trying to automate url redirects via the url rewrite feature on IIS. 我正在尝试通过IIS上的url重写功能自动进行url重定向。 I was wondering what options were available for doing this?
我想知道有哪些选项可以做到这一点?
I found out that you can add a simple rule, and generate the script that is produced as a result. 我发现您可以添加一个简单的规则,并生成结果脚本。 The script exposes the variables which contain your simple rule params and Microsoft have an API available which can be used to add rules this way programmatically.
该脚本公开了包含简单规则参数的变量,Microsoft提供了一个可用的API,该API可用于以编程方式添加规则。 The scripts are available in C#,js,appcmd.
这些脚本在C#,js,appcmd中可用。
However I was wondering if there were other ways that people have used? 但是我想知道人们是否还有其他使用方式? Perhaps editing the xml rules file directly?
也许直接编辑xml规则文件?
your could install the url rewrite module 您可以安装url重写模块
https://www.iis.net/downloads/microsoft/url-rewrite https://www.iis.net/downloads/microsoft/url-rewrite
and add the into web.config 并将其添加到web.config
<rewrite>
<rules>
<rule name="Rewrite to article.aspx">
<match url="^article/([0-9]+)/([_0-9a-z-]+)" />
<action type="Rewrite" url="article.aspx?id={R:1}&title={R:2}" />
</rule>
</rules>
</rewrite>
or add the rule in the iis url rewrite module in the iis manager, 或在iis管理器的iis网址重写模块中添加规则,
don't forget restart the iis after add the change 不要忘记添加更改后重新启动iis
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.