How can we rewrite an URL in Azure Webapp?

0 votes

I have a simple wildcard routing rule I want to apply for my Azure web app.

<rule name="MyRule">
  <match url="*" />
  <action type="Rewrite" url="/index.html" />
</rule>

Do I have any option here given I can't RDP into the machine and fiddle with IIS? This is not an ASP.Net website, it's a simple SPA application.

Jun 14, 2018 in Azure by club_seesharp
• 3,450 points
825 views

1 answer to this question.

0 votes

You need to create a web.config file in your wwwroot folder and put the relevant config entries there.

Here's an example of an web.config rule, to give you an idea of what it should look like.

The below example redirect the default *.azurewebsites.net domain to a custom domain (via http://zainrizvi.io/2016/04/07/block-default-azure-websites-domain)

<configuration>
  <system.webServer>  
    <rewrite>  
        <rules>  
          <rule name="Redirect rquests to default azure websites domain" stopProcessing="true">
            <match url="(.*)" />  
            <conditions logicalGrouping="MatchAny">
              <add input="{HTTP_HOST}" pattern="^yoursite\.azurewebsites\.net$" />
            </conditions>
            <action type="Redirect" url="http://www.yoursite.com/{R:0}" />  
          </rule>  
        </rules>  
    </rewrite>  
  </system.webServer>  
</configuration>
answered Jun 14, 2018 by null_void
• 3,220 points

Related Questions In Azure

0 votes
1 answer

How can we connect Azure Web App to an Azure SQL Database?

Its easy now! Go to your Azure SQL ...READ MORE

answered Aug 8, 2018 in Azure by club_seesharp
• 3,450 points
157 views
0 votes
1 answer

How can I remove/hide/disable excessive HTTP response headers in Azure/IIS7 without having to use UrlScan?

MSDN published an article on how to ...READ MORE

answered May 21, 2018 in Azure by club_seesharp
• 3,450 points
481 views
0 votes
1 answer

How can I replicate an Azure Virtual Machine?

To create a managed image of a ...READ MORE

answered May 23, 2018 in Azure by club_seesharp
• 3,450 points
50 views
0 votes
2 answers

How can I view the deployed files in Azure?

In Visual Studio, in the window "Server ...READ MORE

answered Aug 21, 2018 in Azure by Priyaj
• 56,520 points
250 views
+1 vote
10 answers

How can the NuGet packages be used in Azure Functions?

Yes! Although the Azure Functions portal does ...READ MORE

answered Jun 8, 2018 in Azure by club_seesharp
• 3,450 points
4,651 views
0 votes
1 answer

Can we have more than one Public IP in Azure?

It appears you can now have multiple ...READ MORE

answered Aug 22, 2018 in Azure by null_void
• 3,220 points
28 views
0 votes
1 answer

How to get blob-URL after file upload in azure?

Assuming you're uploading the blobs into blob ...READ MORE

answered Sep 27, 2018 in Azure by null_void
• 3,220 points
1,795 views
0 votes
1 answer

Can I use an appsettings.json file in Azure Functions?

Only environment variables are supported for app ...READ MORE

answered Apr 24 in Azure by Prerna
• 1,940 points
447 views
0 votes
1 answer

How to determine the number of messages in an Azure Services Bus Queue?

You will get error when you try ...READ MORE

answered Jun 12, 2018 in Azure by null_void
• 3,220 points
202 views
0 votes
1 answer

How can we load a list of Azure blob files recursively?

Actually, there's a simpler way to do ...READ MORE

answered Aug 13, 2018 in Azure by null_void
• 3,220 points
2,124 views