Have you published your project on IIS?If so ,you can use Url rewrite to solve your problem. Or do you just want to implement Url rewrite through code by using 'RewriteOptions()'? Please describe your Problem in detail.
Best Regards,
Jerry Cai
.NET forums are moving to a new home on Microsoft Q&A, we encourage you to go to Microsoft Q&A for .NET for posting new questions and get involved today.
None
0 Points
4 Posts
Url rewrite to different domain
Oct 26, 2020 01:45 AM|PhaniVemireddy|LINK
We are trying to dstribue the one application api requests to different application apis.
For example:
1. [POST] https://{domain1}/api/authentication to [POST] https://{domain2}/api/authentication
2. https://{domain1}/api/Persons to https://{domain3}/api/Persons (depends on header values)
Is there a way this can be implemented at global level like middleware or something like this?
I have tried below aoption, but not working. It seems url rewriting working only for same domain.
var options = new RewriteOptions()
.AddRewrite(@"api/values", "https://av21.azurewebsites.net/api/home", true);
app.UseRewriter(options);
Participant
980 Points
321 Posts
Re: Url rewrite to different domain
Oct 26, 2020 07:45 AM|Jerry Cai|LINK
Hi,PhaniVemireddy
Have you published your project on IIS?If so ,you can use Url rewrite to solve your problem. Or do you just want to implement Url rewrite through code by using 'RewriteOptions()'? Please describe your Problem in detail.
Best Regards,
Jerry Cai
None
0 Points
4 Posts
Re: Url rewrite to different domain
Oct 26, 2020 01:39 PM|PhaniVemireddy|LINK
Thank you, Jerry.
You are right Jerry, I am looking for the solution at the middleware level using "ReqriteOptions()".
It is hosted on Azure Linux App Service and using Kestrel. Not sure I can configure Rewrite rules on the app service.
Regards,
Phani
All-Star
58194 Points
15658 Posts
Re: Url rewrite to different domain
Oct 26, 2020 02:09 PM|bruce (sqlwork.com)|LINK
You want urlredirect, not urlrewrite
https://docs.microsoft.com/en-us/aspnet/core/fundamentals/url-rewriting?view=aspnetcore-3.1
None
0 Points
4 Posts
Re: Url rewrite to different domain
Oct 26, 2020 04:41 PM|PhaniVemireddy|LINK
Oops!!!
Thank you, Bruce.
I have read that link couple of times, but for some reason, my eyes didn't catch "AddRedirect".
I will try it.
Regards,
Phani