简体   繁体   中英

Specific Redirect/Rewrite Rule for web.config

Can someone assist with a redirect rule?

I would like to swap any occurrence of, say, "newjersey", anywhere in the url for "new-jersey".

Any suggestions on how to do this via web.config would be great, as I need to do this right away. TIA!

Got it working via the following:

<rule name="Redirect {1}/newjersey" stopProcessing="true">
<match url="^([^/]+)/newjersey$" ignoreCase="false" />
<conditions trackAllCaptures="true">
  <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
  <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Redirect" url="/{R:1}/new-jersey" appendQueryString="false" />

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