简体   繁体   中英

Is it possible to rewrite a URL with a dot to NOT include the dot using IIS URL Rewrite?

I'm using IIS 7.5 with URL Rewrite.

I have old legacy urls out on the web that point to urls like this:

http://www.domain.com/games/dog-vs.-cat
http://www.domain.com/games/john.smith-ran-away

I need these urls to be rewritten without the dot:

http://www.domain.com/games/dog-vs-cat
http://www.domain.com/games/johnsmith-ran-away

Here's my rule that is not working.

<rule name="RedirectOldURL" stopProcessing="true">
      <match url="^games/([a-zA-Z0-9-]+)$" />
      <action type="Redirect" redirectType="Permanent" url="/games/{R:1}" />
</rule>

Is it possible to rewrite the source url without the dot? The dot could appear anywhere in that last piece of url.

Thanks

In action use

<match url="^games/([0-9]+)/([_0-9a-z-]+)" />

and in action block use:

url="games.aspx?id={R:1}&amp;title={R:2}"

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