如何将 .htaccess 转换为 web.config?

How to convert a .htaccess to web.config?

我必须将 htaccess 转换为 web.config。

主要的重定向是删除旧的 .aspx 扩展名。然后对重命名文件进行一些单独的重定向。

htaccess:

<IfModule mod_rewrite.c>
 RewriteEngine On

 # redirect aspx to extensionless
 RewriteRule ^(.+)\.aspx$  [NC,L,R=301]

 # old page redirects
 Redirect 301 /folder/old-file http://www.website.com/new-file
 Redirect 301 /folder/old-file-2 http://www.website.com/new-file-2

</IfModule>

在 IIS 中,此规则将是:

<rule name="redirect aspx to extensionless" stopProcessing="true">
    <match url="^(.+)\.aspx$" />
    <action type="Redirect" url="{R:1}" />
</rule>            
<rule name="old 1" stopProcessing="true">
    <match url="^folder/old-file$" />
    <action type="Redirect" url="http://www.website.com/new-file" />
</rule>         
<rule name="old 2" stopProcessing="true">
    <match url="^folder/old-file-2$" />
    <action type="Redirect" url="http://www.website.com/new-file-2" />
</rule>