繁体   English   中英

如何将.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$ $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>

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM