mercredi 7 octobre 2020

How to configure domain/path rewrite in azure web app

Good,

I'm trying to do a url rewrite from a path to a different domain in an azure web app. I have a case that works and another that doesn't.

Case 1. This case works:

I have domain A (test.com) and I want to rewrite requests to domain B (example.com) preserving domain A in the URL that the user sees in the browser.

Step 1: I enabled the reverse proxy: applicationHost.xdt

<? xml version = "1.0" encoding = "utf-8"?>
<configuration xmlns: xdt = "http://schemas.microsoft.com/XML-Document-Transform">
  <system.webServer>
    <proxy xdt: Transform = "InsertIfMissing" enabled = "true" preserveHostHeader = "false" reverseRewriteHostInResponseHeaders = "false" />
  </system.webServer>
</configuration>

Step 2: Create a rewrite rule web.config

<rules>
<rule name = "rule 1">
<match url = "(. *)" />
<action type = "Rewrite" url = "https://example.com/" appendQueryString = "true" logRewrittenUrl = "false" />
</rule>
</rules>

This works without a problem.

Case 2. This case does NOT work:

I have domain / path A (test.com/path) and I want to rewrite requests to domain B (example.com) preserving domain / path A in the URL that the user sees in the browser.

Step 1: I repeated previous step 1

Step 2: Create a rewrite rule web.config

<rules>
<rule name = "rule 2">
<match url = "path" />
<action type = "Rewrite" url = "https://example.com/" appendQueryString = "true" logRewrittenUrl = "false" />
</rule>
</rules>

What is happening is that the rewrite is OK but any access to a file from "domain b" gives a 404. enter image description here

What would be the correct configuration for case 2 to work?

Thank you very much




Aucun commentaire:

Enregistrer un commentaire