简体   繁体   中英

asp.net url rewrite with dynamic parameter

I use asp.net C# and need a to make an URL rewrite rule that maps a long URL to a short url, and keep the dynamic URL parameter (guid):

Example:

The first URL (short) should be mapped / redirected to the long url below:

Short URL:

http://www.domain.com/campaign.aspx?guid=db7b1e74-f45a-4756-945f-33e812534c09

Long URL:

http://www.domain.com/templates/sections/user/misc/campaign/freemember.aspx?guid=db7b1e74-f45a-4756-945f-33e812534c09

The GUID parameter is dynamic created, so I cannot hard code that in the rewrite rule. Hope someone can help me creating this rewrite rule :)

I have not had to do this before, but maybe this will be of use to you.

https://sourceforge.net/projects/shorturl-dotnet/

I solved this:

<rewrite>
  <rules>
    <rule name="RewriteUrl">
      <match url="^campaign/([_0-9a-z-]+)" />
      <action type="Rewrite" url="/templates/sections/user/misc/campaign/freemember?id={R:1}" />
    </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