简体   繁体   中英

Can I make this web.config rewrite rule?

In web.config I would like to set up the following rule for my ASP.NET project:

A request to:

mydomain.com/123/some-page

returns page

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

In other words

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

The visitor should still see the domain/x/y in the browser url.

Can I make such a rewrite rule?

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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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