简体   繁体   English

IIS重写模式不起作用

[英]IIS Rewrite pattern not working

I have a rewrite pattern that I can't get to work. 我有一个无法使用的重写模式。

if someone goes to my site by using this url: 如果有人使用以下网址访问了我的网站:

http://example.com/article/page/1?_escaped_fragment_= http://example.com/article/page/1?_escaped_fragment_=

I would like my rewrite pattern to match the querystring and then rewrite my path to 我希望我的重写模式匹配querystring,然后将我的路径重写为

/snapshots/snapshot_article_page_1.html /snapshots/snapshot_article_page_1.html

I tried writing a rule like this: 我尝试编写如下规则:

    <rule name="Seo rewrite rule" stopProcessing="true">
      <match url="(.*)"/>
      <conditions>
        <add input="{QUERY_STRING}" pattern="(.*)_escaped_fragment_=(.*)" />
      </conditions>
      <action type="Rewrite" url="/assets/snapshots/snapshot__{REQUEST_URI}.html" appendQueryString="false" />
    </rule>

But I just keep getting a 404 error (even though the page exists!). 但我只是不断收到404错误(即使该页面存在!)。 I even tried actually putting in the full URL to the page and it doesn't work, but if I put the URL in the browser, it shows it fine. 我什至尝试将完整的URL放入页面中,但它不起作用,但是如果将URL放入浏览器中,它会很好地显示。

It appears I have done it. 看来我已经做到了。 The rule to match my example would be this: 匹配我的示例的规则是这样的:

<rule name="Seo rewrite rule" stopProcessing="true">
  <match url="(.*)"/>
  <conditions>
    <add input="{QUERY_STRING}" pattern="(.*)_escaped_fragment_=(.*)" />
  </conditions>
  <action type="Rewrite" url="/assets/snapshots/snapshot__{R:0}.html" appendQueryString="false" />
</rule>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM