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

时间:2017-08-09 12:55:12

标签: apache .htaccess web-config

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

主要重定向是删除旧的.aspx扩展名。然后为重新命名的文件重新定向一些。

htaccess的:

<IfModule mod_rewrite.c>
 RewriteEngine On

 # redirect aspx to extensionless
 RewriteRule ^(.+)\.aspx$ $1 [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>

1 个答案:

答案 0 :(得分:1)

在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>