locked
Rewrite does redirection instead of rewrite RRS feed

  • Question

  • User-186651909 posted

    Hi,

    We have a problem with some Rewrite rules. We make a rule to rewrite on a non public subdomain

    Eg: www.test.com/test supposed to rewrite on new.test.com/test

    The things are, when we tested it in the browser like this

    www.test.com/test 

    that's redirect to new.test.com/test

    If we had manually a slash it works. that's make the rewrite

    www.test.com/test/

    Thanks for your help

    Wednesday, July 26, 2017 8:38 PM

Answers

  • User-186651909 posted

    I close this ticket. Seems to be not clear. I'll create a new thread.

    • Marked as answer by Anonymous Tuesday, September 28, 2021 12:00 AM
    Tuesday, September 19, 2017 7:55 PM

All replies

  • User-460007017 posted

    Hi steveddd,

    Could you provide your rewrite rule? Besides, do you have any global redirect rule on server level? If you need www.test.com/whatever to new.test.com/whatever, you could use this rule:

    <rule name="rewrite to new">
                        <match url="(.*)" />
                        <conditions trackAllCaptures="true">
                            <add input="{URL}" pattern="(.*)" />
                            <add input="{HTTP_HOST}" pattern="www.test.com" />
                        </conditions>
                        <action type="Rewrite" url="http://new.test.com{C:1}" />
                    </rule>

    In addition, if you used to set the rewrite to redirect and accessed the website, the 301permernant redirect could lead to a long term browser cache in your web browser. So please clean the browser cache first.

    If the steps above doesn't resolve the issue, please enable the failed request tracing and post the log:
    https://docs.microsoft.com/en-us/iis/extensions/url-rewrite-module/using-failed-request-tracing-to-trace-rewrite-rules

    Best Regards,

    Yuk Ding

    Thursday, July 27, 2017 7:45 AM
  • User-186651909 posted

    Thanks Yuk,

    Just to explain our needings correctly. We have 3 server farms (v1, v2 and v3) Just ahead of that, we have a redirect server we call ARR.

    ARR : received requests and rewrites it to V1, V2 or V3.
    V1 : ASP
    V2-V3 : ASP.net

    The only one farm cannot process the rewrite correclty is the V1. But the rules are the same.

    V1 rules :
                    <rule name="V1 " stopProcessing="true">
                        <match url="^((test|test2)(/.*)?)" />
                        <conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
                        <action type="Rewrite" url="http://v1.test.com/{R:0}" logRewrittenUrl="true" />
                    </rule>
    V2 rules :
                    <rule name="V2" stopProcessing="true">
                        <match url="^((test3|test4)(/.*)?)" />
                        <conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
                        <action type="Rewrite" url="http://v2.test.com/{R:0}" logRewrittenUrl="true" />
                    </rule>

    Thursday, July 27, 2017 2:39 PM
  • User-2064283741 posted

    I'm not sure if these rules work. It looks like the pattern match is all messed up for what you want.

    I think all URLs that are like test3/ will match the first rule. (RegEx matching here)

    Use the Test Pattern in the GUI and try different examples.

    Thursday, July 27, 2017 7:14 PM
  • User-186651909 posted

    Hi,

    It works in the GUI, everything works fine. The problem happens only in the web browser when we don't add a "/" after a URL.

    Steve

    Wednesday, August 2, 2017 8:05 PM
  • User-460007017 posted

    Hi steveddd,

    Are you sure everything works fine? I notice www.test.com/test3 will trigger the first rewrite rule while this URL match the V1 rule.

    I think the URL should be modified to

    ^((test|test2)(/.*)?$)

    In addition, try to clean the browser cache. Just check whether inspect the incoming request in server farm routing rule has been checked.

    Best Regards,

    Yuk Ding

    Tuesday, August 8, 2017 3:24 AM
  • User-186651909 posted

    I close this ticket. Seems to be not clear. I'll create a new thread.

    • Marked as answer by Anonymous Tuesday, September 28, 2021 12:00 AM
    Tuesday, September 19, 2017 7:55 PM