Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Simon Dingley 1470 posts 3427 karma points c-trib
    Jun 01, 2017 @ 08:27
    Simon Dingley
    0

    RESPONSE_STATUS Returns 200 When Browser Console Shows Http Header is 404

    I have a large site which has a considerable number of content items getting published and unpublished on a daily basis. When an item is deleted or unpublished I want to redirect it to it's parent so have a rule that looks as follows:

      <rule name="OldHotelPages" stopProcessing="false">
        <match url="^(.*)/hotels/(.+)/$" />
        <conditions logicalGrouping="MatchAny">
          <add input="{RESPONSE_STATUS}" pattern="^404$" ignoreCase="true"/>
          <add input="{RESPONSE_STATUS}" pattern="^410$" ignoreCase="true"/>
        </conditions>
        <action type="Redirect" appendQueryString="true" redirectType="Permanent" url="/{R:1}/hotels/" />
      </rule>
    

    If I visit a page in my browser that has been unpublished I get the following headers:

    Request URL:http://localhost:51294/uk/guide/hotels/another-hotel/
    Request Method:GET
    Status Code:404 Not Found
    Remote Address:[::1]:51294
    

    But in the trace logs where I am trying to debug the rule I get the following:

    • RuleName OldHotelPages
    • RequestURL uk/guide/hotels/another-hotel/
    • QueryString
    • PatternSyntax Regex
    • StopProcessing false
    • RelativePath /

    • Pattern ^(.*)/hotels/(.+)/$

    • Input uk/guide/hotels/another-hotel/
    • Negate false
    • Matched true

    Great, we have matched the request path! However, the issue I have is when it comes to matching the conditions in my rule, the trace shows the following:

    • Input {RESPONSE_STATUS}
    • ExpandedInput 200
    • MatchType Pattern
    • Pattern ^404$
    • Negate false
    • Succeeded false

    The ExpandedInput shows a status of 200 which is different to the response header seen in the browser?

    I'm a bit stumped at this point. Any ideas?

    Thanks, Simon

Please Sign in or register to post replies

Write your reply to:

Draft