2017-09-14 43 views
0

在web.config中,我想建立以下规则为我的ASP.NET项目:我可以制作这个web.config重写规则吗?

的请求:

mydomain.com/123/some-page 

返回页面

mydomain.com/collection/123-some-page.html 

换句话说

domain/x/y should fetch and return domain/collection/x-y.html 

访问者仍然应该看到域/ x/y在额头ser网址。

我可以制定这样的重写规则吗?

回答

1

记住要在IIS中安装 URL重写模块和web.config

<rewrite> 
    <rules> 
    <rule name="My rewrite"> 
     <match url="^(.*)/(.*)$" /> 
     <action type="Rewrite" url="collection/{R:1}-{R:2}.html" /> 
    </rule> 
    </rules> 
</rewrite> 
设置如下规则
相关问题