-1

I am trying to test a web application locally. This runs on a domain such as https://abc

We have some services which are created on direct links such as /services/findmesomething

These services do not work locally, so ideally I'd like to point them to our QA resources which are on public links such as https://abc.somedomain.com/. More specifically I'd like to request the data from https://abc.somedomain.com/services/findmesomething

https://abc/services/findmesomething >> should point to >> https://abc.somedomain.com/services/findmesomething

StuartM
  • 6,943
  • 16
  • 76
  • 142
  • Your question is VERY unclear. URLs do not point to other URLs, they define resource locations. "Services do not work locally" is very vague -- there is always a host, always. Don't things work when served through e.g. `file` scheme? Consequently, there isn't a well defined meaning for the term "locally", "abc" may refer to a host on a LAN or WAN, which is it? "Requesting data" can be many things. Sorry, I'd like to help, and I am pretty sure I can, but I just don't know what your question is. – amn Sep 15 '19 at 19:26
  • Ok, the services in question do not work locally as the relevant database connections are not available locally. They are already configured for our QA environment which is on a public domain. The idea was to direct the request traffic/post from the local domain to the public one instead. The question is whether this can be done via host file change or something else, or should it be a code change in the application. Hopefully, that brings some light to the question. – StuartM Sep 15 '19 at 19:29

1 Answers1

0

It seems that you want to point the url to abc.somedomain.com, if the pattern is the services/findmesomething .

If this is your requirement, I suggest you could consider using url rewrite. You could install it from this url.

Then I suggest you could add below config into your web.config.

<system.webServer>
    <rewrite>
        <rules>
            <rule name="test">
                <match url="services(.*)" />
                <action type="Rewrite" url="https://abc.somedomain.com/{R:0}" />
            </rule>
        </rules>
    </rewrite>
</system.webServer>

Update url rewrite rule:

<system.webServer>
    <rewrite>
        <rules>
            <rule name="test">
                <match url="services(.*)" />
         <conditions>
         <add input="{REMOTE_ADDR}" pattern="the server IP address" />
         </conditions>
                <action type="Rewrite" url="https://abc.somedomain.com/{R:0}" />
            </rule>
        </rules>
    </rewrite>
</system.webServer>
Brando Zhang
  • 15,923
  • 6
  • 23
  • 48
  • The problem is we only want this to occur locally. So wondered if it was possible without a code change/elsewhere. Because ultimately we could do a isLocal check on the request and change the URL – StuartM Sep 17 '19 at 10:25
  • You could try to use condition to check the client IP address, if the client IP address is your server ip, then this url rewrite rule will work. More details about the url rewrite rule, you could refer to my update answer. – Brando Zhang Sep 20 '19 at 07:46