【问题标题】:Redirect old page to new page usign web.config使用 web.config 将旧页面重定向到新页面
【发布时间】:2021-02-09 16:30:52
【问题描述】:

我需要将旧页面的 url 重写到新页面,例如: 老:https://www.mysite.it/scheda.asp?num=123456 新:https://www.mysite.it/scheda/?num=123456

我在 web.config 中添加了以下几行但不起作用,当我转到 https://www.mysite.it/scheda.asp?num=123456 注意到发生时,网站无需重写即可转到页面:

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

我试试这个:

<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>

什么都没有发生,似乎我所做的所有改变都没有影响

【问题讨论】:

标签: iis url-rewriting


【解决方案1】:

您可以尝试以下规则,如果您有任何问题,请告诉我:

<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>

【讨论】:

    猜你喜欢
    • 2013-02-14
    • 2022-01-22
    • 2021-03-02
    • 2012-10-11
    • 1970-01-01
    • 2018-02-07
    • 2011-09-24
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多