我可以重写这个 web.config 规则吗?
Can I make this web.config rewrite rule?
在 web.config 中,我想为我的 ASP.NET 项目设置以下规则:
请求:
mydomain.com/123/some-page
returns 页
mydomain.com/collection/123-some-page.html
换句话说
domain/x/y should fetch and return domain/collection/x-y.html
访问者仍应在浏览器中看到 domain/x/y url。
我可以制定这样的重写规则吗?
记得在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>
在 web.config 中,我想为我的 ASP.NET 项目设置以下规则:
请求:
mydomain.com/123/some-page
returns 页
mydomain.com/collection/123-some-page.html
换句话说
domain/x/y should fetch and return domain/collection/x-y.html
访问者仍应在浏览器中看到 domain/x/y url。
我可以制定这样的重写规则吗?
记得在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>