locked
Capture Redirects URLs RRS feed

  • Question

  • User-1552835106 posted

    We are using the URL Rewrite module to handle a bunch of redirects.   We would like to track which ones are actually being used still so we can get rid of the other ones.   Any suggestions on tracking this information?

        <rewrite>
            <rules>

                  <rule name="sales.domain.com" enabled="true" stopProcessing="true">
                    <match url="( .*)" negate="true" />
                    <conditions logicalGrouping="MatchAll">
                      <add input="{HTTP_HOST}" pattern="sales.domain.com$" />
                    </conditions>
                    <action type="Redirect" url="https://www.domain.com/Sales" />
                  </rule>

                  <rule name="marketing.domain.com" enabled="true" stopProcessing="true">
                    <match url="( .*)" negate="true" />
                    <conditions logicalGrouping="MatchAll">
                      <add input="{HTTP_HOST}" pattern="marketing.domain.com$" />
                    </conditions>
                    <action type="Redirect" url="https://www.domain.com/Marketing" />
                  </rule>
                  
                  ..... 30 more just like this            
                            
             </rules>
         </rewrite>

    Friday, March 5, 2021 1:03 PM

All replies

  • User690216013 posted

    If all such rules are "Redirect", you can simply analyze IIS log files for 301 lines to see which rules are being used actively.

    Saturday, March 6, 2021 12:52 AM
  • User-1552835106 posted

    Thanks for the reply.   Yeah.  All of the rules are setup like my example.   I see a 301 but since I have 30+ redirects in the same web.config, how do I know which ORIG URL was used?  Here is the snippet of the IIS log.

    #Fields: date time s-ip cs-method cs-uri-stem cs-uri-query s-port cs-username c-ip cs(User-Agent) cs(Referer) sc-status sc-substatus sc-win32-status time-taken
    2021-03-06 00:00:00 10.254.2.15 GET / - 80 - 10.254.1.48 Mozilla/5.0+(compatible;+PRTG+Network+Monitor+(www.paessler.com);+Windows) - 301 0 0 

    Saturday, March 6, 2021 4:19 AM
  • User690216013 posted

    The original URL is preserved in server variables, URL Rewrite Module Configuration Reference | Microsoft Docs so that you can write that to IIS log files via enhanced logging Enhanced Logging for IIS 8.5 | Microsoft Docs

    Saturday, March 6, 2021 4:01 PM
  • User1771714573 posted

    Hi Scott Wade,

    An easy way is that you can temporarily set all rules to rewrite. Then enable failed request tracing to collect the process of rewrite. 

    In log of failed request tracing, you can see which rule is useful and which rule isn't working.

    Best regards,

    Brucz

    Monday, March 8, 2021 9:00 AM
  • User-1552835106 posted

    I have been trying the Enhanced logging and haven't found the exact Source Type and Source combination that will show me either the sales.domain.com or marketing.domain.com URL that was entered by the website visitor.    

    Let me explain my IIS setup a little more just in case it matters.   I have two sites setup.  One called REDIRECT and one called MAINSITE.   The REDIRECT site just has a web.config that has all of the Rewrite rules setup (Action=Redirect),    All of the rules redirect to the MAINSITE that is running DNN (DotNetNuke).  

    I obviously don't understand logging in IIS.  I was thinking it would show an entry in the REDIRECT IIS log every time one of the rewrite URLs were used.   It appears to just write to the log every once in awhile.  Like once a day.   

    I tried using the netsh http flush logbuffer command but it still doesn't write to the IIS log for every website visit.   I tried clearing the client's cache but that didn't seem to make a difference.   Any help on this would be very appreciative.  Otherwise, I have to wait until the IIS log gets updated before I know my change worked.

    Thanks,

    Scott

    Monday, March 8, 2021 12:27 PM
  • User1065476709 posted

    Hi scott wade,

    I have been trying the Enhanced logging and haven't found the exact Source Type and Source combination that will show me either the sales.domain.com or marketing.domain.com URL that was entered by the website visitor.    

    Let me explain my IIS setup a little more just in case it matters.   I have two sites setup.  One called REDIRECT and one called MAINSITE.   The REDIRECT site just has a web.config that has all of the Rewrite rules setup (Action=Redirect),    All of the rules redirect to the MAINSITE that is running DNN (DotNetNuke).  

    I obviously don't understand logging in IIS.  I was thinking it would show an entry in the REDIRECT IIS log every time one of the rewrite URLs were used.   It appears to just write to the log every once in awhile.  Like once a day.   

    I tried using the netsh http flush logbuffer command but it still doesn't write to the IIS log for every website visit.   I tried clearing the client's cache but that didn't seem to make a difference.   Any help on this would be very appreciative.  Otherwise, I have to wait until the IIS log gets updated before I know my change worked.

    I suggest you use failed request tracking to get detailed error messages.

    https://docs.microsoft.com/en-us/iis/troubleshoot/using-failed-request-tracing/troubleshooting-failed-requests-using-tracing-in-iis-85.

    Best regards,

    Sam

    Thursday, March 25, 2021 8:58 AM