How to redirect in app service

디엔소프트 DNSOFT 196 Reputation points
2020-12-10T08:48:40.263+00:00

I'm using an app service, and if I have a domain called test.com, I want to know how to redirect to test.com when I connect to www.test.com

Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
7,030 questions
0 comments No comments
{count} votes

Accepted answer
  1. brtrach 251 Reputation points
    2020-12-11T04:36:15.48+00:00

    To rewrite a URL, you need to create a web.config file in your wwwroot folder and put the necessary entries in there, if you don't already have a web.config file for your site.

    <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>
    

    Source: https://www.zainrizvi.io/blog/block-default-azure-websites-domain/

    0 comments No comments

0 additional answers

Sort by: Most helpful