I have an Angular application hosted in Azure. Users want open app by pasting specific url to the browser (https://somehosting.com/myapp/product/detail/123) by it can’t be opened that way it redirects to https://somehosting.com not even https://somehosting.com/myapp.
If I paste in a browser https://somehosting.com/myapp it can be opened but if I paste full url with product Id it can’t be opened.
Anyone encountered such a problem? Any help would be appreciated
2
Answers
In the past I run into similar issue. If you are using Azure web apps, I would use a web.config file. This solved my issue last time. Add this web.config file to the root of your application. This sets the rewriting rules for IIS to ‘/’.
That config should looks like this
That url should be reflected by href inside your index.html.Make sure that the tag in your index.html is set correctly. Or if your application is hosted under /myapp, then you should set it to . This ensures that Angular’s router knows the correct base path for all its routes.
Try to create the following web.config file on the root level of your angular application, like the one below.
On some occasions, I had to configure the URL rewrite in Azure portal.
https://learn.microsoft.com/en-us/azure/application-gateway/rewrite-url-portal