Redirect sub.example.com/login to example.com/wehavemoved

Antonio Savage 6 Reputation points
2020-01-07T05:05:55.88+00:00

Hello I have a site hosted on Azure in the App Services service. I then have an application gateway in front of that app acting as a WAF and it's a v1 appgateway.

I need to figure out how to redirect sub.example.com/login to example.com/wehavemoved. I was able to figure out how to redirect sub.example.com to example.com/wehavemoved, but now that redirect (using listeners and rules in the appgateway), is injecting the /wehavemoved path into all requests. So when I try to visit sub.example.com/login, it redirects to sub.example.com/wehavemoved/login. Is there anyway in Azure that I can make it so that both the sub.example.com and sub.example.com/login both redirect to example.com/wehavemoved?

I can add any additional information as requested.

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

2 answers

Sort by: Most helpful
  1. Joffrey NURIT 206 Reputation points MVP
    2020-01-07T12:15:56.71+00:00

    Hi,
    Some solutions can help you, depend of your configuration.

    Have you Linux or Windows app service? .net app or not?

    You have .Net core app for example, you can use the Kestrel Middleware to redirect some route.
    https://learn.microsoft.com/fr-fr/aspnet/core/fundamentals/routing?view=aspnetcore-3.1

    The best solution is to use system middleware. If you are on windows App Service, it's IIS. You can change this with web.config file. web.config file act like .htaccess for apache. You can add rules to redirect some route on another, and attribute an HTTP redirect code for SEO.

    An example:
    alt text

    1 person found this answer helpful.
    0 comments No comments

  2. Stephen Weinrich 6 Reputation points
    2020-05-04T00:21:01.333+00:00

    Look at Path Based Routing: https://learn.microsoft.com/en-us/azure/application-gateway/redirect-overview

    I would also recommend upgrading to Application Gateway V2.

    1 person found this answer helpful.
    0 comments No comments