在web.config中,我想为我的ASP.NET项目设置以下规则:
请求:
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。
我可以制作这样的重写规则吗?
In web.config I would like to set up the following rule for my ASP.NET project:
A request to:
mydomain.com/123/some-pagereturns page
mydomain.com/collection/123-some-page.htmlIn other words
domain/x/y should fetch and return domain/collection/x-y.htmlThe visitor should still see the domain/x/y in the browser url.
Can I make such a rewrite rule?
最满意答案
请记住在IIS中安装url rewrite模块,并在web.config设置下面的规则
<rewrite> <rules> <rule name="My rewrite"> <match url="^(.*)/(.*)$" /> <action type="Rewrite" url="collection/{R:1}-{R:2}.html" /> </rule> </rules> </rewrite>Remember to install url rewrite module in IIS and set below rule in 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重写规则吗?(Can I make this web.config rewrite rule?)在web.config中,我想为我的ASP.NET项目设置以下规则:
请求:
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。
我可以制作这样的重写规则吗?
In web.config I would like to set up the following rule for my ASP.NET project:
A request to:
mydomain.com/123/some-pagereturns page
mydomain.com/collection/123-some-page.htmlIn other words
domain/x/y should fetch and return domain/collection/x-y.htmlThe visitor should still see the domain/x/y in the browser url.
Can I make such a rewrite rule?
最满意答案
请记住在IIS中安装url rewrite模块,并在web.config设置下面的规则
<rewrite> <rules> <rule name="My rewrite"> <match url="^(.*)/(.*)$" /> <action type="Rewrite" url="collection/{R:1}-{R:2}.html" /> </rule> </rules> </rewrite>Remember to install url rewrite module in IIS and set below rule in web.config
<rewrite> <rules> <rule name="My rewrite"> <match url="^(.*)/(.*)$" /> <action type="Rewrite" url="collection/{R:1}-{R:2}.html" /> </rule> </rules> </rewrite>
发布评论