Domain rewrite to www with Application Gateway

RT-7199 511 Reputation points
2022-12-15T20:59:32.883+00:00

Are we able to rewrite domain in Azure Application gateway

example.com to www.excample.com

Can someone help with how the rewrite looks like for this

Azure Application Gateway
Azure Application Gateway
An Azure service that provides a platform-managed, scalable, and highly available application delivery controller as a service.
1,217 questions
0 comments No comments
{count} votes

Accepted answer
  1. GitaraniSharma-MSFT 50,096 Reputation points Microsoft Employee Moderator
    2022-12-16T19:30:18.413+00:00

    Hello @RT-7199 ,

    Welcome to Microsoft Q&A Platform. Thank you for reaching out & hope you are doing well.

    I understand that you would like to know if it is possible to rewrite a domain with www using Azure Application gateway.

    It should be possible via a simple listener redirect configuration in your Application gateway.
    Refer : https://learn.microsoft.com/en-us/azure/application-gateway/redirect-overview
    https://learn.microsoft.com/en-us/azure/application-gateway/redirect-internal-site-powershell

    Once you create an Application gateway and point it's IP address to your custom domain name i.e. example.com, you should be able to access the Application gateway via that domain name. Post this if you want to make sure that the URL example.com, when accessed should redirect to www.example.com, you can just add another listener with hostname "www.example.com" and make sure that the previous listener with hostname "example.com" redirects to the newly added listener.

    Below are the screenshots from my lab which shows the configuration and result:

    • Created an Application gateway with a single HTTP multi-site listener with host name "azurelabs.tk".
    • Created an "A" record to point the IP address of my Application gateway to the domain name "azurelabs.tk".
    • Then created another HTTP multi-site listener with host name "www.azurelabs.tk".

    271409-image.png

    • Edited the existing app gateway rule to redirect the listener 1 to listener 2.

    271511-image.png

    • Created a new rule for listener 2 to forward traffic to my backend pool using the HTTP settings.

    271465-image.png

    • Now. if I access my Application gateway using azurelabs.tk, it redirects to www.azurelabs.tk as below:

    271410-image.png

    Kindly let us know if the above helps or you still need assistance with rewrites.

    ----------------------------------------------------------------------------------------------------------------

    Please "Accept the answer" if the information helped you. This will help us and others in the community as well.


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.