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
8,203 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>


Hope this helps!!

If you need to know more about Azure, then you should join Microsoft Azure certification course today.

Thank you!!

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 9, 2018 in Azure by club_seesharp
• 3,450 points
6,505 views
0 votes
1 answer
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 22, 2018 in Azure by club_seesharp
• 3,450 points
3,453 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
528 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
• 58,090 points
4,448 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
16,189 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 23, 2018 in Azure by null_void
• 3,220 points
526 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
15,297 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
4,179 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 14, 2018 in Azure by null_void
• 3,220 points
18,678 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP