question

skumbag avatar image
1 Vote"
skumbag asked azure-cxp-api edited

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

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-webapps
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

JoffreyNURIT-4769 avatar image
0 Votes"
JoffreyNURIT-4769 answered

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://docs.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




exemple.png (7.5 KiB)
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

StephenWeinrich-3740 avatar image
0 Votes"
StephenWeinrich-3740 answered

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

I would also recommend upgrading to Application Gateway V2.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.