0

i need to rewrite the url from old page to new page, an example: old: https://www.mysite.it/scheda.asp?num=123456 new: https://www.mysite.it/scheda/?num=123456

i've put in web.config the following lines but don't work, when i go to https://www.mysite.it/scheda.asp?num=123456 noting happen, site go to the page without rewrite:

  <rule name="scheda-rew" stopProcessing="true">
      <match url="scheda.asp(.*)" />
      <action type="Rewrite" url="scheda/{R:1}" logRewrittenUrl="true" />
  </rule>

i try this:

<rule name="scheda-rew2" stopProcessing="true">
    <match url="^scheda\.asp" ignoreCase="true" />
    <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
    <add input="{QUERY_STRING}" pattern="isbn=([0-9]+)" />
    </conditions>
    <action type="Redirect" url="scheda/{C:1}" appendQueryString="false" />
</rule>

nothing appen, seem that all change i do haven't effect

antlego
  • 33
  • 4
  • 1
    Does this answer your question? [IIS URL Rewrite not working with query string](https://stackoverflow.com/questions/19165676/iis-url-rewrite-not-working-with-query-string) – Lex Li Feb 09 '21 at 19:11
  • Thnak you, probabilly i don't understand, but i need to make it work on every page https://www.mysite.it/scheda/?num=\d+ of my new site, but don't work, why? – antlego Feb 09 '21 at 21:57
  • @LexLi see the edit – antlego Feb 09 '21 at 22:57
  • https://learn.microsoft.com/en-us/iis/extensions/url-rewrite-module/using-failed-request-tracing-to-trace-rewrite-rules Learn how the rule works internally, and you probably can then know what to change. – Lex Li Feb 10 '21 at 01:32

1 Answers1

0

You can try below rule, if you have any question please let me know:

<rule name="RewriteUserFriendlyURL2" stopProcessing="true">
   <match url="^scheda.asp\?([^/]+)/?$" />
       <conditions>
            <add input="{​​​​​​​REQUEST_FILENAME}​​​​​​​" matchType="IsFile" negate="true" />
            <add input="{​​​​​​​REQUEST_FILENAME}​​​​​​​" matchType="IsDirectory" negate="true" />
            <add input="{​​​​​​​REQUEST_URI}​​​​​​​" pattern="^scheda/$" negate="true" />
       </conditions>
   <action type="Redirect" url="scheda/?num=123456" appendQueryString="false" />
</rule>
samwu
  • 3,857
  • 3
  • 11
  • 25